This seems to be giving me a bit of trouble. This method is supposed to generate a random number and assigns it to a char. getline grabs the entire string from the text file and assigns it to foods. y has the purpose of holding the place of where it finds c in the foods string. It will then use that int to erase from the string and print out whats left.
I keep getting a "Program has requested to shutdown due to a runtime error in an unusual way" and it locks up. Thanks in advance.
void feedRandomFood()
{
int y = 0;
int x = rand() % food.size() + 1; //assigns x a random number between 1 and food.size MAX
char c = '0' + x; //converts int to char for delimiter char.
ifstream inFile;
inFile.open("OatmealFood.txt", ios::in);
string foods = "";
getline(inFile, foods);
inFile.close();
y = foods.find(c);
foods.erase(y); //erase characters up to the char found
cout << foods;
}