C++ Struct Question

dubstar

format c:
Joined
3 Dec 2002
Messages
1,357
my first Struct:

Code:
struct menuType		//struct definition
{
	string itemName;	//name of item
	double itemPrice;	//price of item
};

string getMenu()
{
	ifstream menuList;
	menuList.open("menuList.txt");
	if (menuList.is_open())
	{
		while (! menuList.eof())
		{
			cin.getline (menuInfo.itemName,menuInfo.itemPrice);
		}
	}
};


what am i doing wrong ?? 🙁
 
i was trying to open a file, read it, and then have each line stored into alternating variables.

the first line would be itemName, then itemPrice. until the end of the file.

thanks for the link.
 
where does menuInfo come from? You might need an input string stream (istringstream) but I'm not sure.
 

Members online

No members online now.

Forum statistics

Threads
62,021
Messages
673,242
Members
5,640
Latest member
Kgkass
Back
Top