Originally Posted by
laserlight
hmm... you are right, it is the one and only standard std::basic_istream manipulator, apparently.
What is your current code?
I've solved the problem. In another program (the final for the course) where I was doing the same 'getline()', I discovered that the length of separate strings (getline vs. cin[ifstream]) were different. One was one more character than the other. getline() was 1 longer, apparently because of a null character (or something, I'm not even sure). Do you have any idea what could have caused it?
I had to use this to get rid of the suspect final character, for the regular assignment, on the end:
Code:
type[i].menuItem.erase(type[i].menuItem.length() -1, 1)
this was the function that included the above: (menuItem is string, menuPrice is double)
Code:
void getData(menuItemType type[])
{
ifstream readFile;
readFile.open("Ch11_Ex3Data.txt");
int i = 0;
for (i = 0; i < ITEMS_ON_MENU; i++)
{
getline(readFile, type[i].menuItem, '\n');
type[i].menuItem.erase(type[i].menuItem.length() -1, 1);
readFile >> type[i].menuPrice;
readFile.ignore(1, '\n');
}
readFile.close();
}
I can see that this characteristic (overwriting a line) might come in handy, but would also like to know exactly how to implement it. So far, I have no clue.