Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>assert</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
assert

Usage

   #include <assert.h>
   void assert(expression);

   ANSI

Description


   The assert macro is useful for adding internal consistency checks to
   programs. When the assert macro is executed it checks the expression
   argument and if it is zero, then the following message is printed on the
   standard error device and the program aborts.

   Assertion failure: 'expression' on line ?? in file '???'

   The assert function can be deactivated by defining the macro NDEBUG prior
   to the inclusion of assert.h header file. This has the effect of turning
   all assertions into null statements.

Example 

   #include <assert.h>
   #include <stdio.h>
   #include <stdlib.h>

   char *string = "";      /* empty string */
   int value = 1;


   int main()
   {
       assert(value > 0);
       printf("Passed assert(value > 0)\n");
       assert(*string != '\0');
       return EXIT_SUCCESS;
   }




Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson