Http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.1.html.
Author: Eric Huss
Chinese translator: Liu jinhong poechant
Copyright Disclaimer: the original text in this article is copyrighted by Eric Huss, and the Chinese translation is copyrighted by poechant. Reprinted please indicate from "LIU Da's csdn blog": http://blog.csdn.net/poechant
1.1 assert. h
The assertion header file is used for debugging.
MACRO:
Assert ();
External Reference:
Ndebug
1.1. Assert
Statement:
Void assert (intExpression);
Macros in the assertion header file allow you to write some special information to the standard error file.
If the expression value is 0 (false), the expression, source file name, and row number are all sent to the standard error output and the abort function is called. If the identifierNdebug
("No debug")# Define ndebugDefinition, then the macro in the header file will not do anything.
The format of standard error output is as follows:
Assertion failed:Expression, FileFilename, Line
Line-Number
Instance:
# Include <assert. h>
Void open_record (char * record_name)
{
Assert (record_name! = NULL );
/* Rest of code */
}
Int main (void)
{
Open_record (null );
}
(1) assert. HC standard Library Reference Guide series (2) ctype. HC standard Library Reference Guide series (3) errno. HC standard Library Reference Guide series (4) float. HC standard Library Reference Guide series (5) limits. HC standard Library Reference Guide series (6) locale. HC standard Library Reference Guide series (7) math. HC standard Library Reference Guide series (8) setjmp. HC standard Library Reference Guide series translations (9) signal. HC standard Library Reference Guide series translations (10) stdarg. HC standard Library Reference Guide series (11) stddef. HC standard Library Reference Guide series translations (12) stdio. H ()
Copyright Disclaimer: the original text in this article is copyrighted by Eric Huss, and the Chinese translation is copyrighted by poechant. Reprinted please indicate from "LIU Da's csdn blog": http://blog.csdn.net/poechant
-