assert( ) macro...
We can use a macro called assert( ) to test for conditions that should not occur in a code. This macro expands to an if statement. If test evaluates to 0, assert prints an error message and calls abort to abort the program.
We can use a macro called assert( ) to test for conditions that should not occur in a code. This macro expands to an if statement. If test evaluates to 0, assert prints an error message and calls abort to abort the program.
#include
#include
void main( ) {
int i ;
cout << "\nEnter an integer: " ; cin >> i ;
assert ( i >= 0 ) ; cout << i << endl ;
}
EmoticonEmoticon