Vote count:
0
I am trying to read a file. The file contents have a newline between words in a sentence and two newlines between sentence. I can only read one sentence. I have tried to put a EOF as a delimiter in getline but it seems not to work. Does anyone have any suggestions on how to resolve this?
string line;
string a, b;
ifstream infile("myFile");
while (getline(infile, line))
{
istringstream iss(line);
if (!(iss >> a >> b)) { break; } // error
cout << a << b << endl;
}
asked 21 secs ago
Aucun commentaire:
Enregistrer un commentaire