Thread: Wy am i getting this error message?

  1. #1
    Registered User
    Join Date
    Feb 2010
    Location
    Seattle Washington
    Posts
    20

    Wy am i getting this error message?

    Code:
    #include<iostream>
    #include<string>
    
    using namespace std;
    
    int main()
    {
    	double money;
    	string food;
    	int quantity;
    	double price = 1.25;
    	double total;
    	char reply = 'y';
    
    
    	do
    	{
    		cout << "Enter Food:";
    		getline(cin,food);
    
    		if (food == "tacos")
    		{
    			cout << "How Many: ";
    			cin >> quantity;
    
    			total = price * quantity;
    
    			cout << "Total :"<< total<<endl;
    
    			cout << "More Items: ";
    			cin >> reply;
    		} 
    	
    
    		else
    		{
    			cout << "No Item Found" <<endl;
    		} while (reply == 'y' || reply == 'Y');
    	}
    
    	return 0;
    
    }
    error message
    Code:
    error C2059: syntax error : 'return'

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Count your curly braces.

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Your while is also in the wrong place.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed