Specification: Display a menu
Find Errors in this program

#include "stdafx.h"
#include <iostream> //change io to iostream
#include <string>
using namespace std; // added

I get the Error 1 error C2065: 'choice' : undeclared identifier line 17 which is 'choice'

What am i missing?

int main ()// added int
{ //reversed this symbol


cout << "Choose From Martha's Menu:\n"; //reversed <<
cout << "1 - Dinner"; // added ;
cout << endl << " 2 - Lunch"; //correct endl and added ;
cout << endl << "3 - Breakfast"; //corrected endl and added ;
cout << "Enter a number:";
std::cin >> choice;
int choice = 0;
cout << "You Choose " << choice;


;return 0;
}

Next time please use the code tags

[code]

code goes here

[/code]

Why do you declare choice after you try to write to it? You need to move int choice = 0; before std::cin >>choice;

Thank you so much! I cant believe it was right in front my my face.

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.