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:
(they need some real C++ highlighting, so it says C++ code: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") != 0 && 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") != 0 && strcmp(user_choice, "u") != 0 &&
strcmp(user_choice, "O") != 0 && strcmp(user_choice, "o") != 0 &&
strcmp(user_choice, "H") != 0 && strcmp(user_choice, "H") != 0 &&
strcmp(user_choice, "Q") != 0 && strcmp(user_choice, "q") != 0);
return user_choice[1];
}
)




)
Reply With Quote