void parseLine(string line) { stringstream ss(line); string word; while(getline(ss,word,' ')) { if(word == "Done") { return; //return; //HERE: Is there a way from here to return back to main? } } } void parseFile(string filename) { fstream infile(filename); string line; while(getline(infile,line)) parseLine(line); } int main() { parseFile("filename.txt"); cout << "Done! " << endl; return 0; }
int parseLine(string line) { stringstream ss(line); string word; while(getline(ss,word,' ')) { if(word == "Done") { return 0; } } return 1; }
while(getline(infile,line) && parseLine(line)); // <<-- semicolon
parseLine
true
false
while(getline(infile,line)) { if(parseLine(line)) { break; } }
break;
return;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)