I am reading in data to a struct array. the data is separated by possible blank lines which i must ignore. my code is not working im wondering why
struct Location
{
string state;
string city;
int zipcode;
}
and heres the reading in im getting trouble with.
while (!fin.eof() && size < 50)
{
getline (fin, location[size].state);
getline (fin, location[size].city);
fin >> location[size].zipcode;
if (location[size].empty()) //to ignore blank lines but its not working?
continue;
size++;
}
any ideas? could it be the compiler?
It looks like you are trying to check for an empty string but are unintentionally trying to call
empty()on aLocation.Did you mean
Edit:
If you would like for your code example to work as is and you are able to modify
struct Loactionyou could do the following.