|
From: Kevin W. <ke...@me...> - 2001-12-22 12:19:18
|
Change the type of " number " to char.
The output will probably still be not you want, so I would use e.g. :
cout << "\tIs digit?: ";
if(isdigit(number))
cout << "Yes" << endl;
else
cout << "No" << endl;
----- Original Message -----
From: Exuss Draugas <dra...@ce...>
To: <Dev...@li...>
Sent: Saturday, December 22, 2001 8:10 AM
Subject: [Dev-C++] Checking data type
>
>
> Hi, All! :)
>
> How to check input data type from the console? For example, I need
> only number, and how to check that some letters wasn't entered?
>
> This code shows doesn't work for me, if I try to enter some number,
> it shows a zero in every condition. ://
>
> #include <stdlib.h>
> #include <ctype.h>
> #include <iostream.h>
>
> void main()
> {
>
> int number;
> cout << "\n\tInput number or letter: ";
> cin >> number;
> cout << "\n\tIs alnum?: " << isalnum(number) << endl;
> cout << "\tIs digit?: " << isdigit(number) << endl;
> cout << "\tIs alpha?: " << isalpha(number) << endl;
> cout << "\tIs lower?: " << islower(number) << endl;
> cout << endl;
> system("PAUSE");
> }
>
> Are there other way to check what was entered from console, digital
> number or text ???
>
> Thanx,
>
> Exuss :)
>
|