help with identifier

This is a discussion on help with identifier within the C++ Programming forums, part of the General Programming Boards category; i super new to c++ and i'm taking the second semester course, which i never took the first, so it's ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    7

    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

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Code:
    int getValidInt(char *prompt);
    Put that at the top right after including the necessary headers.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,654
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21