ch2-assert
Chapter_2 tempfile | open |
assert.c ALP, p. 38
#include <stdio.h> // for NULL
// stdio,h includes stddef.h, which defines NULL:
// /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:
// #define NULL ((void *)0)
#include <assert.h> // for assert()
int do_something(void) {return 0;}
int main()
{
int i, status;
for (i = 0; i < 100; i++)
{
status = do_something();
assert(status == 0);
}
char *p = NULL;
assert(p != NULL);
return 0;
}
/*
gcc assert.c -o assert
./assert
assert: assert.c:21: main: Assertion `p != NULL' failed.
Aborted (core dumped)
gcc -DNDEBUG assert.c -o assert
./assert
*/
Chapter_2 tempfile | BACK_TO_TOP | open |
Comments
Post a Comment