Ok, i have another question then, upon reading the FAQ, i found a great
way to differentaite between an int and a char in validation. But what
if you user enters 1a. the 1 makes it through my validation, and then
the a messes everything up. Is there a way to take care of that? I am a
student, and this is my first semester in c++ and i have a crafty
teacher who just may do that to see how well my validation is. thanks
'a' doesn't mess things up. '1' will be interpreted as the int you wanted
to input. The rest of the stream (what comes after a valid number) is
usually non-consequential. Of course, you could write a more clever
validation algorithm according to more complicated rules you are willing
to impose, but AFA I'm concerned "1a" string does contain a valid integer.
What you do after '1' has been extracted is up to you. You could try to
go back to reading and report invalid input or stop if the input has been
exhausted. You could simply ignore the rest of the input. You could read
the input as a string an analyze it char by char and only if the sequence
in its entirety represents a number (in your understanding), accept it,
and report an error otherwise. The choices are many.
BTW, 1a is a valid hexadecimal value.
V