Page 61 - C-Language
P. 61

}


        Now, if the assertion fails, an error message will read something like this


              Assertion failed: p != NULL && "function f: p cannot be NULL", file main.c, line 5


        The reason as to why this works is that a string literal always evaluates to non-zero (true). Adding
        && 1 to a Boolean expression has no effect. Thus, adding && "error message" has no effect either,
        except that the compiler will display the entire expression that failed.

        Read Assertion online: https://riptutorial.com/c/topic/555/assertion











































































        https://riptutorial.com/                                                                               37
   56   57   58   59   60   61   62   63   64   65   66