Is there any where to check what users input, in a simpler way?
cout<<"What is your name : ";
Am I able to also set all to CAPS? In that cin statement?
cout<<"what is your age : ";
Can I put a check that it is integer?
As long as userAge is a integer, you need no check, and the checks are done from the STL.
As long as you write such:
userAge will be a integer, and if user inputs something wrong, he will have to write twice the input.
If you want to set all text in upper case, get the text and loop in all the string with a "toupper" function (Example:
unsigned int Length = strlen(Text);
for(unsigned int i = 0; i < Length; ++i)
Text[i] = toupper(Text[i]);
// Now Text is uppercase.
You can also get raw text and convert it to Number with atoi or strtoul/strtol/strtod.
You also have the opposite way (itoa). There is no ftoa unless you make your own routine.
Last edited on
What about checking for strings that is integers only?