|
From: Wobien <wo...@pl...> - 2003-10-09 14:44:28
|
Using assert is supposed to be a big help in finding bugs in your program.
#include <cassert>
assert(a<b);
should stop your program if a>=b and print the file and line number of the
assert statement that failed, if and only if you run in debug mode. If you
are not in debug mode, the assert statements should not be compiled.
Now I have 2 problems:
1: my program stops if the assert fails, even if I did not compile in the
debug mode.
2: when the program stops it does not wait and stop to give me the
opportunity to read the message about the file and line number. The system
("PAUSE"); statement at the end of the main procedure does not help here,
because the program never gets there.
A simple test "program" to try this is:
#include <stdlib.h>
#include <cassert>
int main()
{
int a=5;
int b=1;
assert(a<b);
system ("PAUSE");
return 0;
}
|