Is it possible to check whether a line is empty in a stream? This is the part where I like to be more picky then just taking every row:
1 2 3 4
while ( infile.good() ) {
getline (infile,line);
//cout << line << endl; //test ok if infile is prepared.
}
The 'program' is taking a file and chops in into pieces and I would prefer to have it ignore break row empty rows etc. Just to make it easier to use, it's for a friend and he's not exactly a computer nerd.
You could simply add if(line != "") ... to ignore empty lines, though that won't work if there is a space on that line.
You could add infile >> ws;//needs <iomanip> before getline to ignore any white spaces, but this will also remove spaces (up to the first non space) from lines that contain text.
If these don't work, you'll have to write your own function bool isNotJustSpaces(string str). Simply iterate through the given string and if any char is not ' ' or '\t' (tab), return true.