I’m beginner in programming (specially in C++). I’ve tried to check incoming symbols for letters. I need to “catch” only numbers from 0 to 9. So, i try to use it:
// Checking "a". If "a" is a letter, the error must be printed;
if (a!='%d') {
cout << "pfff! U cant use letters!" << endl;
return -1;
}
// The end of checking;
But it doesn’t work. I guess that i can’t use ‘%d’ in C++. How i can say:
“Check all symbols and stop the program if there will be non-numbers.”
P.S. Sorry for my english. I hope u got me.
Yes ,
isdigit()will work out nicely here .An example is :