C Standard Library Reference Guide (1) assert.h

Source: Internet
Author: User

1.1 Assert.h

The assertion header file is used for debugging.

Macro:

ASSERT ();

External references:

Ndebug

1.1. Assert

Statement:

void assert (intexpression);

A macro in the assertion header file allows you to write some special information to a standard error file.

If the expression has a value of 0 (false), then the expression, the source file name, and the line number are sent to the standard error output and the Abort function is invoked. If the identifier Ndebug ("No Debug") is defined by #define NDEBUG, the macro in the assertion header file does nothing.

The standard error output is formatted 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);    

}

Original English: http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.1.html

Original Author: Eric Huss

Chinese translator: Liu Yong poechant

Copyright: The original copy of this article is owned by Eric Huss, and the Chinese translation is poechant All rights reserved. Reprint please specify from "Liuda csdn blog": http://blog.csdn.net/poechant

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.