read file in 3d array of character

Apr 16, 2011 at 2:43pm
hi, i have to read a file containing email addresses of different people in following format
name@domain.com:40
after reading i have to maintain 4 arrays
1: email domain
2: email name
3: email title
4: number of visits e.g in above example number of visits is 40,

i hope you will help me....
Apr 16, 2011 at 2:51pm
You don't need four arrays, let alone a 3D array - one is enough:

Use a class similar to this one:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class EMailAddress
{
  public:
    EMailAddress(const std::string& str)
    {
      //split string here using getline, boost::string::split or similar
    }
    //getters
    [...]
  private:
    std::string name;
    std::string domain;
    int visits;
};


When reading the file, store the addresses in a vector of that class.
Last edited on Apr 16, 2011 at 2:51pm
Topic archived. No new replies allowed.