C++ Reading from a txt file

Started by
1 comment, last by Justaddwater 20 years, 1 month ago
Ok I can write to a file fine, but when trying to read i get stuck can anyone enlighten me as to what im doing wrong?

if (infile.fail()!= true)
{
	while (!(infile.eof()))
	{
		
	
			infile >> FoodID;
	
			if (strcmp(FoodID,"Dairy")==0)
				readdairy();
			if (strcmp(FoodID,"Fruit")==0)
				readfruit();
			if (strcmp(FoodID,"Meat")==0)
				readmeat();
			system ("pause");
			//FoodID[0] = '\0';

			
		
		}
}

		infile.close();
[edited by - justaddwater on March 18, 2004 3:33:30 AM]
Advertisement
at what point in the code u r getting stuck..?? hope u have opened the file using .open...
Tough times don''t last,Tough people Do.
yeah it was open, my problem was with reading it , i needed to add a cin.ignore prior to a getline

This topic is closed to new replies.

Advertisement