C assert (assert.h) Library
C assert Macros
The <assert.h> header has the assert() macro. It checks a condition while the program runs. If the condition is false, the program prints an error message and stops.
Use it to find mistakes in your own code while you test it.
| Macro | Description |
|---|---|
| assert() | Stops the program with an error message, if a condition is false |
| static_assert | Checks a condition when the program is compiled (C11). The same as the _Static_assert keyword |
| NDEBUG | This macro is not defined in <assert.h>. If you define it before you include <assert.h>, all assert() checks are turned off |
Related Pages
Read more about finding mistakes in our C Debugging Tutorial.