-
help with identifier
i super new to c++ and i'm taking the second semester course, which i never took the first, so it's kinda hard for me with the syntax and all. here's my issue:
Code:
int getMenuOption()
{
int menuOption;
cout << "Please make a selection:" << endl;
cout << "1. Enter information for a plane." << endl;
cout << "2. View information for a plane." << endl;
cout << "3. Exit the program." << endl;
menuOption = getValidInt("Enter the menu option: "); // <-- 'getValidInt': identifier not found
return menuOption;
}
int getValidInt(char *prompt)
{ // <-- 'getValidInt' : redefinition; previous definition was 'formerly unknown identifier'
const int MAX = 80;
char buffer[MAX];
int i;
cout << prompt;
cin.getline(buffer, MAX);
while (strlen(buffer) != strspn(buffer, "1234567890"))
{
cout << "Invalid integer - please re-enter: ";
cin.getline(buffer, MAX);
}
i = atoi(buffer);
return i;
}
i hope this is all the code needed to figure it out. thanks
-
Code:
int getValidInt(char *prompt);
Put that at the top right after including the necessary headers.
-
If you indent your code, you will find it much easier to follow, and people on message board will be more inclined to help you.