I am trying to read from a file like this
1 23 5 15
3 18 8 6 11
But then whenever it goes to the last string "15", it also reads "3" from then next line.
Here is my code for this part:
ifstream myFileRent;
myFileRent.open("rented.txt");
if (!myFileRent.is_open())
{
cout << "ERROR: File is corrupted or does not exists!";
}
while (!myFileRent.eof())
{
getline(myFileRent, customerID, ' ');
while (getline(myFileRent, video_ID, ' '))
{
InsertCusRent(stoi(customerID), video_ID);
}
}
This is what it shows in debug when I am in the "15" before the next line "3"
video_ID : "15\n3" : std::string
Basically, first digit of the line will go to customerID, and every next digits will be pushed in to stack, which is why I used while because every line are not equal in length.