Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>assert() diagnostic message generator</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 assert()                Diagnostic Message Generator

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

 void       assert(expression);          condition to be evaluated.
 int        expression;

    assert() tests 'expression'. If 'expression' fails, assert() prints a
    diagnostic message and aborts the calling process.   No action is
    taken if 'expression' is true (nonzero), so 'expression' should be
    chosen so it is true if the program is operating correctly.

    The diagnostic message has the form:

       Assertion failed: 'expression', file 'filename', line 'linenumber'

    where 'filename' is the source file name and 'linenumber' is the line
    where assert() appears.  assert() is used to identify program logic
    errors.

       Returns:     No return value

         Notes:     assert() is a macro.

                    If NDEBUG is defined (with any value), the C
                    preprocessor removes all assert() calls from the
                    program.  NDEBUG can be defined via the -D command-
                    line option, or with a #define directive.

   -------------------------------- Example ---------------------------------

    The following statement tests whether pshift is NULL and prints an
    appropriate message.

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

           struct BASE {
                  char *name;
                  int number;
           } *pshift;

           main()
           {
               assert(pshift != NULL);
                 /* process item */
           }




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