what happens if the user is asked to input a number or even comes from a file
and u wanna check if the input is really numbers and not something liek 124a
how would u check that
isdigit wont work on it cuz it requires a character
cheers
Printable View
what happens if the user is asked to input a number or even comes from a file
and u wanna check if the input is really numbers and not something liek 124a
how would u check that
isdigit wont work on it cuz it requires a character
cheers
>>isdigit wont work on it cuz it requires a character
try using a loop!
my input is an int
not a char array
you have 2 strategies.
1) use member functions of ios to decide whether input is good.
2) get all input as a string and parse what u want from it.
look up ios::fail(),ios::bad(),ios::clear(),ios::good(), etc. in your helpfiles. For strategy 2 look up stringstreams.
how would i use the ios::fail and ios::bad here
i mean how would they be set if the int contains a character?