Tips for C

Source: Internet
Author: User

1. If typeof is used as an expression, the expression is not executed. Only the type of the expression is obtained.

2. When ld is linked to a static database, you must first-o and then-l. This is because the ld does not automatically adjust the dependency sequence as it links to a dynamic library.

3, printf ("% f", 1/2); is the output 0.5? No, output 0. To output 0.5, write printf ("% f", (doublle) 1/(double)/2). This is because the C language uses the default value constant as the int type, int type operation. The result 0.5 is rounded to 0.

4. According to the C99 standard, 'A' is called an integer character constant and is regarded as an int type. Therefore, it occupies 4 bytes on 32-bit machines.
According to the iso c ++ standard, 'A' is called character literal, which is regarded as a char type and occupies 1 byte.

In this way, sizeof ('A') = 4 in the. c file, sizeof ('A') = 1 in the. cpp File

5. The number of initialization values can be less than the number of array elements. when the number of initialization values is less than the number of array elements, the corresponding values are initialized in order. The subsequent Initialization is 0 (Global or static array) or an uncertain value (partial array ).

Http://blog.csdn.net/sibylle/article/details/2026915

6. premature optimization is a sin

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.