I am trying to fill out an array by reading data from a txt file. The txt file is in the format: food name
1.99
food name
2.99
I don't understand why my loop in void getData does not reiterate. When I run the program it only works the way I intended for menuList[0], the rest of the indexes have a value of 0.
i=1 getline(infile, menuList[i].menuItem); // reads the \n at the end of the previous price
i=1 infile >> menuList[i].menuPrice; // sends the stream into error state when it cant interpret the food name as a price.
thank you salem you have solved this for me. I had already tried cin.ignore() and couldn't figure out why that still wasn't working. I had to type infile.ignore() which I didn't realize was legal.