Hi guys I know why I am getting an error but I don't know how to solve it
I'm reading from a file called books.txt which contains the following data
what I want to happen is when I reach the last entry in this case Bill I want to discard the : and get to the end of the file,the problem is I get stuck in an infinite loop because it never reaches the end of the file it will always have a left over : thus the loop will never terminate
I tried using in.get() but that didn't work at all and it probably won't solve the problem because it would eat the delimiter which I need in the cases that are not the end case.
cout << "hi" << endl;
ss << d;
ss >> a;
**edit I sort have fixed the infinite loop problem but now I have run into another problem when I try to populate the vector with the data in my books.txt file only adam seems to get added and the rest seem to be discarded for some reason
now everything works fine but question why did adam only get added to the names vector when in.open() was placed in the while loop?
You can only open the file once (unless you subsequently close it first). As it stands, after the second open attempt, the file status will be 'fail' (failed to open an already open file) and so the break statement is executed: