|
From: Exuss D. <dra...@ce...> - 2001-12-27 18:19:27
|
Hi,
Yes, this code above works, but only when ONE(!) simbol is entered.
If I try to enter "4kdkdkd", the output says that the digital number
was entered. I can't use that code in this prototype:
// int weight ??
// char weight ??
// string weight ??
// char[10] weight ??
do
{
cout << "Input Your weight:";
cin >> weight;
// Checking type of entered value
// because the program will crash, if value isn't digital number
// if value is not NUMBER cout << "Please, input number!";
} while ( /* value is bad */ )
// do some calculations with weight
Thanks,
Exuss
>Your code was not proper ANSI C++ too. Your code corrected and fully
>portable:
>
>
>#include <cstdlib>
>#include <cctype>
>#include <iostream>
>
>int main()
>{
> using namespace std;
>
> unsigned char number;
>
> cout << "\n\tInput number or letter: ";
> cin >> number;
>
> if(isalnum(number))
> {
> cout << "\n\tIt is alnum" <<endl;
>
> if(isdigit(number))
> cout << "\tIt is digit" <<endl;
>
> else if(isalpha(number))
> {
> cout << "\tIt is alpha" << endl;
>
> if(islower(number))
> cout << "\tIt is lower"<< endl;
> }
> }
>
>
> cout << endl;
>
> system("PAUSE");
>}
>
>
>
>Ioannis
>
>* Ioannis Vranos
>* Programming pages: http://www.noicys.f2s.com
>* Alternative URL: http://run.to/noicys
>
>
--
Nemokama el.pašto dėžutė - http://webmail.delfi.lt/
|