Hi, I have built a program that imports and reads a file but I am having a small problem with my code. When the file is reading the file it's not stopping at the last row and is including it in the output. Can let me know where I have gone wrong and what I can do to fix?
Because of this !import.eof(). Do not loop on eof (unless you know how it works and it is what you want) it was not created for that. Loop on input operation:
1 2 3 4 5
while(getline(import, name)) { //While read was successfull
int pos = name.find(",");
string last = name.substr(0,pos);
cout << "\"" << last << "\"" << endl;
}