@Zarman. Switch-cases do not work with Strings. You can google that.
@Alex067. You can do it just like you would do it with chars or integers, but instead with strings.
1 2 3 4 5 6 7 8 9 10 11
string choice;
cin >> choice; // use std::getline if you want to have spaces between words
if(choice == "Hello")
{
cout << "from the other siiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiide?" << endl;
}
elseif(choice == "I must") // this one can't be true because there is a white space and you're using std::cin
{
cout << "Have called a thousand tiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiimes" << endl;
}
Yes you can do that with strings too. Not to mention strings got lots of great and useful functions, it keeps it's own size, and it's a lot safer. If you're programming c++ there is really no need to use char pointer.
Using strings like you propose is often error prone, mainly from when the user spells the option incorrectly. You could have a menu with numerical options, and use a switch.
I am guessing you want to call different functions, one can do this with a std::map of function pointers, here is an example from Thomas1965: