I have to write a program for class that will read a datafile into a structure. The data file is a menu of food items at a fast food restaurant. Basically simulate a cash register

I created a structure menu[26] which includes the following elements
key - a,b,c,d etc.
item - hotdog, hamburger etc.
price.

My question is this. What is the best way to create the customers order.

So far I have come up with this

while ((keystroke=getch())!='=')
	{
		cin>>keystroke;
			for (int i=0;i<26;i++)
				if (keystroke=menu[i].key)
				{
					menu[i].item=order[i].item;
					menu[i].price=order[i].price;
				}//end if
	}//end while

However I know that if the customer orders more than soda for example the order will only contain one of that item.

Can anyone suggest a better approach?

why don't you create a struct called menuitem that can store the description/price/etc of one item. Then make an array of all the menu items selected for the order. You could call up the menuitem with a unique key (1,2,3,4...} stored within the struct menuitem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.