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 goes here


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.

This question has already been answered. Start a new discussion instead.