Difference between 0, \ 0, and null

Source: Internet
Author: User

I know where to use it, but the truth is unclear. Then google, a better explanation, although in English, is very classic.

1.0 is an integer constant

2.'\ 0' is a character constant

3.Null is a macro (macro)
Defined in several standard headers (standard header file)

4.Nul is the name of the character constant .. I have never seen it anyway =)

All of these are ** not * interchangeable (not interchangeable)


Their usage is as follows:
1.0 can be used anywhere, it is the generic symbol for each type's zero value and the compiler will sort things out.

2.'\ 0' shoshould be used only in a character context.

3.Null is to be used for pointers only since it may be defined as (void *) 0), this wowould cause problems with anything
But pointers.

4.Nul is not defined in C or C ++, it shouldn't be used unless you define it yourself in a suitable manner, like:# Define
Nul '\ 0'

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.