Originally Posted by
twomers
You should put ,'s in the address and read up to them as substrings. So you'd read between the square brackets then.So you could then use getline and use ',' as a deliminator rather than '\n'
I used commas, and here's how am reading them, but i get a runtime exception on the first getline
Code:
std::istream& operator>>(std::istream& in, Address& address)
{
char *fline="";
char *sline="";
char *tline="";
char *cty="";
char *cde="";
in.getline(fline, 100, ','); /* This throws an exception */
in.getline(sline, 100, ',');
in.getline(tline, 100, ',');
in.getline(cty, 100, ',');
in.getline(cde, 5);
std::string firstln(fline), secondln(sline), thirdln(tline), city(cty), code(cde);
address.setAddress(firstln, secondln, thirdln, city, code);
/*
in >> fline;
in >> sline;
in >> tline;
in >> city;
in >> cde;
*/
return in;
}