Assert () is a macro that is often used when debugging a program. When the program is running, it calculates the expressions in parentheses. If the expression is false (0), the program reports an error and terminates the execution. If the expression is not 0, execute the following statement. This macro often used to determine whether the program contains clearly illegal data. If the program is terminated, it will not cause serious consequences, but also facilitate searching for errors. For example, variable N should not be 0 in the program. If it is 0, an error may occur. You can write the program as follows:
......
Assert (n! = 0 );
K = 10/N;
......
Assert is valid only in the debug version. If it is compiled into the release version, it is ignored.
Assert () has similar functions. It is a function specified in the ansi c standard. An important difference between assert and assert is that it can be used in the release version.