Basic c++ questions

+1 John A · March 25, 2015
Hello everyone and thank you for your help.

Firstly, how can one get normal words to act as integers?

For example I can do:

int x;
cout << "Enter a number " << endl;
cin >> x;

if (x == 6) {cout << "good job" << endl; }
if(x  == 7) {cout << "bad job" << endl;}

So my question is, how can I get the user to input a word instead of number and then run some sort of test on it. I am familiar with the string operator, but it does not seem to behave in the same way as the integer operator.


My second question is how to deal with the user not putting and input in despite have the option too, like if you gave the user an option to list a thousand numbers but they only had five, and then your program just used the five numbers in whatever situation you have prepared for it. Is it just that the input is then the *enter* key or something? And if the user presses *enter* it moves on to the next situation? If so, what syntax would I use to integrate the *enter* key as an actual operation into the program? If not, how do I deal with no input?

NOTE* I tried using the code input button for this post and it messed my whole post up, so I took it out and just put my code as normal text.

Post a Reply


Oldest  Newest  Rating
0 John A · March 26, 2015
Thank you very much for both good sir. I am still new and some of the syntax I don't know about. Thank you.
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator