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?
Originally Posted by laserlight
I had to use this to get rid of the suspect final character, for the regular assignment, on the end:
this was the function that included the above: (menuItem is string, menuPrice is double)
type[i].menuItem.erase(type[i].menuItem.length() -1, 1)
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.
void getData(menuItemType type)
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;