Data Types and variable definitions in C Language tips

Source: Internet
Author: User

Whether a char-type object without the qualifier signed or unsigned is signed depends on the specific implementation.



The dictionary order of characters is actually the ASCII Value Order of Characters in the ASCII table.



The char type actually stores the ASCII integer corresponding to the character, rather than the character itself. Consider the following example:

# Include

 
  
Int main (void) {char ch = 'a'; printf ("% c % d", ch, ch); return 0 ;}

 
The execution result is as follows:

A 97


The Return Value Type of sizeof () is size_t, and size_t must be an integer. Generally, it is an unsigned int or long unsigned int, which is related to the specific implementation.

The operand of sizeof () can be either a type or a variable. When the operand is a type, you must add (). When the operand is a variable, () is dispensable. We recommend that you use () to avoid errors.



Generally, an integer constant without any suffix is regarded as an int type. Other types are used only when its value exceeds the int type.

Consider a floating-point constant without any suffix as a double type.



Ansi c does not allow variable definition in the control part of the for loop, and C99 does, but the scope of this variable is limited to the for loop code block.



The life cycle of the automatic variables defined in the composite statement block starts from the definition to the end of the composite statement block.



If you use register to define a variable as a register type, the address of the variable cannot be obtained.

Related Article

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.