Results 1 to 10 of 10

Thread: [RESOLVED] Returning a Char from a Function

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444

    [RESOLVED] Returning a Char from a Function

    I'm trying to return a single char from a function, but I'm not doing it right. Can someone tell me how? Here's what I have:

    PHP Code:
    #include <iostream.h>
    #include <string>

    char show_choice(bool clear_screen true);

    int main()
    {
        
    char    user_choice[1] = "";
        do    
    //Loop while the users doesn't want to quit
        
    {
            
    //Get the user's choice
              
    user_choice[1] = show_choice();
        } while (
    strcmp(user_choice"Q") != && strcmp(user_choice"q") != 0);
        return 
    0;
    }

    char show_choice(bool clear_screen /*= true*/)
    {
        
    //if (clear_screen == true) ;
        
        
    char user_choice[1] = "";
        do
        {
            
    cout << "U = Enter web page URI\n" <<
                    
    "O = Options\n" <<
                    
    "H = Help\n" <<
                    
    "Q = Quit\n";
            
    cout << "Please enter your choice: ";
            
    cin >> user_choice;
        } while (
    strcmp(user_choice"U") != && strcmp(user_choice"u") != &&
                 
    strcmp(user_choice"O") != && strcmp(user_choice"o") != &&
                 
    strcmp(user_choice"H") != && strcmp(user_choice"H") != &&
                 
    strcmp(user_choice"Q") != && strcmp(user_choice"q") != 0);
        return 
    user_choice[1];

    (they need some real C++ highlighting, so it says C++ code: )
    Last edited by Rick Bull; Sep 13th, 2002 at 12:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width