Definition of NULL in C and C + + languages

Source: Internet
Author: User
Tags define null

Statement A pointer variable does not automatically allocate any memory.  A null pointer is a pointer that does not point to anything. It can be assigned to a pointer to indicate that the pointer does not point to any position. The consequences of performing an indirect access operation on a null pointer vary depending on the compiler, and two common consequences are a value that returns zero in memory location and a terminating program.  I declare a pointer and assign a value of NULL to see the definition of NULL in VS2013, as follows:
/**/#ifndef null#ifdef __cplusplus#define NULL    0#else  / * __cplusplus */#define NULL    ((void *) 0)#endif/  * __cplusplus */#endif  /* NULL */
It contains some precompiled directives. If NULL is not defined in the preceding code, I define NULL in C + + with a value of 0, otherwise ((void *) 0);  You cannot dereference a null pointer at the same time. 

Definition of NULL in C and C + + languages

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.