Test for non-integer values:
Consider some cases:
Case-1: If you want to check user input through input device, such as keyboard then monitor kbhit() in Dossy application or WM_KEYDOWN message in windows application and check that user has pressed the keys from 0..9, '.', +|-
Case-2: I am sure you don't want to check case-1. so consider the following.
int x, y, z;
x = 65; // value of x is 65
y = 'A'; // value of y is 65
z = -'A'; // value of z is -65
Nothing amazing in C language, because in C, int and byte are fundamental data types which takes 2 byte and 1 byte allocation space in memory in 16 bit computers. Hence, compiler can put 1 byte or 8 bits easily in to the lower register i.e. AL But reverse is not true. Also, C is not not strong type checking language. Consider the following.
int x, y, z;
char ch;
x = 'A; // value of x is 65
ch = x; // value of ch is ??? ==> 'A'
In this case compiler will not even issue a warning at assignment statement ch = x; because int and char both are signed types, but you will loose lower byte of variable x.
Case-3: Now all these discussion you want a data type which will hold only an integer numerical value and nothing else. For this consider the OOPS. In C++, you can create your own data type from the basic data types and design and use it the way you want. Consider the following object TInt instead of standard integer data type int.
class TInt {
INT nNum;
public:
TInt():nNum(0) {}
TInt(INT n): nNum

{}
TInt(const TInt& rhs) { nNum = rhs.nNum; }
operator int() const { return (int)nNum; }
TInt &operator =(const TInt& rhs) { nNum = rhs.nNum; return *this; }
TInt &operator =(INT n) { nNum = n; return *this; }
TInt &operator =(char c) { TRACE("some thing is wrong.\n"

; return *this; }
TInt &operator +=(const TInt &rhs) { nNum += rhs.nNum; return *this; }
TInt &operator -=(const TInt &rhs) { nNum -= rhs.nNum; return *this; }
TInt &operator *=(const TInt &rhs) { nNum *= rhs.nNum; return *this; }
TInt &operator /=(const TInt &rhs) { nNum /= rhs.nNum; return *this; }
};
Usage of type TInt:
TInt num1, num2, num3;
num1 = 3;
num2 = num1;
num3 += num2;
num1 = 3 + num2 * num1 + 5;
You can have all the possible operators in this object. But for your problem consider the following two operator functions.
TInt &operator =(INT n) { nNum = n; return *this; }
TInt &operator =(char c) { TRACE("some thing is wrong.\n"

; return *this; }
Yes, you are right. Now when you will say...
TInt num1, num2;
num1 = 'A'; // this will display a warning message.
num2 = 65; // no warning
Suhas Tambe.
Thu. Aug. 15, 2002