Zubair Z
04-10-2007, 12:02 AM
...of x and y in a 'for loop'.? The program is terminated by the assert() macro as soon as the condition x < y becomes false. Initialize y to 3 and increment x in a 'for loop'. When x reaches the value 3, the macro should display the output on stderr, which is always the display screen. Not only do you get the condition that failed displayed, but you also get the file name and line number in the file where the failure occurred. This is particularly useful with multifile programs in which the source of the error is pinpointed exactly.
Sample Output
x = 0 y = 3
x = 1 y = 3
x = 2 y = 3
x = 3 y = 3
Assertion failed: x
Sample Output
x = 0 y = 3
x = 1 y = 3
x = 2 y = 3
x = 3 y = 3
Assertion failed: x