Thread: Menu Trouble

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    21

    Menu Trouble

    I'm having trouble in getting the function in my program below to print out the menu, anu ideas?

    Code:
    #include <iostream>
    
    int MenuAndMenuChoice();
    
    int main()
    {
        
        int MenuAndMenuChoice();
        
        std::cin.get();
        return 0;
    }
    
    int MenuAndMenuChoice()
    {
        
        int MenuChoice;
        
        std::cout << "Add";
        std::cout << "Subtract";
        std::cout << "Multiply";
        std::cout << "Divide";
        std::cout << "Circle Area";
        std::cout << "Circle Circumference";
    
        std::cout << "What would you like to do? ";
        std::cin >> MenuChoice;
        
        return MenuChoice;
        
    }

  2. #2
    Registered User
    Join Date
    Sep 2003
    Posts
    38
    Should this works, let me know. add'.h'

    #include <iostream.h>

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    21
    Nope, the above didn't work.

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    Quote Originally Posted by ComDriver
    I'm having trouble in getting the function in my program below to print out the menu, anu ideas?

    You never invoked (called) the menu function.

    Go back to your original <iostream>, and change main():

    Code:
     int main()
    {
        
        int MenuAndMenuChoice(); // this is the prototype declaration
        
        MenuAndMenuChoice(); // this is the invocation
        std::cin.get();
        return 0;
    }
    Regards,

    Dave
    Last edited by Dave Evans; 02-20-2005 at 12:57 PM.

  5. #5
    Registered User Scribbler's Avatar
    Join Date
    Sep 2004
    Location
    Aurora CO
    Posts
    266
    Actually MenuAndMenuChoice() has been declared twice. Once before main and once within main. Change the prototype in main into a function call.

  6. #6
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    And don't add '.h' to the iostream header. <iostream> is standard, <iostream.h> is not.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  7. #7
    Registered User
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    91
    *** slaps Lord CyKill around a bit with a large trout ***

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Trouble with systray menu
    By geek@02 in forum Windows Programming
    Replies: 3
    Last Post: 05-06-2005, 10:19 AM
  4. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM