|
From: Ioannis V. <no...@ho...> - 2002-11-26 20:07:18
|
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of
Olu...@ao...
Sent: Tuesday, November 26, 2002 11:53 AM
To: dev...@li...
Subject: [Dev-C++] Function Syntax C++
I want to write a function that will validate my C++ prgram. I want the
function to display a message if wrong value type is entered. For
example -
int number1;
cout << " Enter your number. The number must be between 1 and 4: " ;
cin >> number1;
if the user enter, a char value instead of a int value, i want the
function to display a message of violation of variable type.
Is it possible to write this type of function and what is the syntax.
thnaks
olu...@ao...
if(cin.fail())
{
cin.ignore();
cerr<<"\nYou entered crazy things!\n";
}
Ioannis Vranos
* Programming pages: <http://www.noicys.freeurl.com/>
http://www.noicys.freeurl.com
* Alternative URL: <http://run.to/noicys> http://run.to/noicys
|