Differences between null and NUL

Source: Internet
Author: User
Tags define null

NullIs a macro defined as a null pointer in the header file <stddef. h>. Nul is the name of the first character in the ASCII character set. It corresponds to a zero value. The C language does not contain predefined macros such as NUL. Note: In the ASCII character set, digit 0 corresponds to a decimal value of 48. Do not mix digits 0 with '/0' (NUL) values.

NullCan be defined(Void *) 0, AndNulCan be defined'/0'. Both null and NUL can be simply defined as 0. They are equivalent and can be used interchangeably, but this is an undesirable method. To make the program read clearer and easier to maintain, you should define null as the pointer type and NUL as the character type in the program.

 

You can obtain the value of a pointer by performing the unreferencing operation. From the definition, the NULL pointer does not point to anything. Therefore, it is invalid to unreference a null pointer. Before unreferencing a pointer, make sure it is not a null pointer.

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.