So.. I am a beginner and I was creating a really "basic" calculator, I thought about what should the program do if the input was a letter instead of a number, I would use a lot of IF/else statements, clear.cin , ignore.cin, every time one of the inputs was wrong. Afterwards, I thought I would make a function to automatically check if the input was an integar, and that's what came in mind first :
bool checkInputDouble (char x)
{
if (x>0 || x<0 || x==0)
{return true;}
else
{return false;}
}
I thought that these would apply to any number but not to a letter or any other character, however, it didn't work. After several trials, i found out the omitting the "x==0" condition would solve the problem, as SOMEHOW, the program thought of other characters as they equals zero. The function did its job and the calculator worked perfectly, but I thought that wasn't a practical solution, may be I will need to make a program where the user enters a number, but zero is an important input, I thought there must be like a statement or a function I don't know that would do the job, so any help ? can someone tell me what a function that REALLY does the job will look like ? and so for a function that checks for letters only, etc. Thanks in advance.