Deep understanding of the difference between ' 0 ' and ' 0 ' ' + ' 0

Source: Internet
Author: User

It seems that the foundation is still very important, the foundation is not solid on the hard to learn C language, don't say to write high-quality C language code. Today, I was tortured by this problem, haha, but now finally understand the ' to ', ' 0 ', ' 0 ' the difference between. Confused and happy to share with you!

First, compare the difference between ' \ ' and ' 0 '. One thing in common is that they are all characters, and in C, characters are stored in the ASCII code they correspond to, one byte for each character. Please open your ASCII character set table, usually in the appendix of your C language textbook, do not check online. Please see the first ASCII code, the pair is 0, the corresponding word is (Null), is actually ' "", that is, the null character. The flag that determines whether a string is ended is to see if it encounters ' \ ' and, if it encounters '/', the end of the string. and the character ' 0 ' corresponds to the ASCII code is 48,48 corresponding hexadecimal number is 0x30, usually we in the programming, when the character converted to a number often used, such as to convert ' 8 ' to the number 8, in the statement so write, "8+ ' 0 '". The 8 here is the number. The difference between the characters ' 0 ' and the number 0 is that the former is a character constant, and the latter is an integer constant, and their meaning is very different from the way they are stored in the computer. However, character constants can participate in the related operations in the program like integers. For example: ' 9 '-3;. Haha, is not vista AH.

Next we compare the difference between "0" and "0". First, "0" is a string constant, and a string constant is a sequence of characters enclosed by a pair of double quotes. For example: "China", "I Love You", "123" and so on are all valid string constants. ' 0 ' is a character constant, and the string constant and character constant are different amounts. 1: Character constants are enclosed in single quotes, and string constants are enclosed in double quotation marks. 2: Character constants can only be single characters; string constants may contain one or more characters. Here we first introduce the main differences in the expression, in the use of storage space and different ways of assignment and so on. Here is just a point, specific to the C language related books. This is to summarize, hope to you useful, thank you!

Transferred from:

Deep understanding of the difference between ' 0 ' and ' 0 ' ' + ' 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: 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.