1-C traps and defects 1 in the computer classic book series

Source: Internet
Author: User

By Andrew Koenig, translated by Gao Wei, reviewed by Wang Xin

C traps and pitfalls

Andrew Koenig and C ++

Absolute classic

1. Greedy method in lexical analysis: each symbol should contain as many characters as possible

2. If the first character of an integer constant is 0, it is regarded as an octal value. 0100 = 64, not binary

3. printf ("Hello \ n"); with Char Hello [] = {'h', 'E', 'l', 'l', 'O ', '\ n', 0}; printf (Hello); equivalent

4. function pointer int (* FP) (); can be abbreviated as int FP ()

5. Simple priority: calculation> relationship> shift> Logic

6. It is best to write a semicolon next to struct a {...}. Some compilers will not report errors.

7. else always matches the nearest if in the same bracket

8. The C language only has a one-dimensional array, and the size of the array must be determined during compilation.

9. Multi-dimensional arrays are simulated by one-dimensional arrays.

10. int A [32] [11]; meaning that A is an array with 32 Elements and each element has 11 integer variables.

11. for int A [32] [11]; If int I = A [4] [5]; you can write it as I = * (a + 4) + 5 ); or I = * (a [4] + 5 );

12. int A [32] [11]; int (* AP) [11]; ap =;

13. As a function parameter, the array name is converted to a pointer pointing to the first element of the array.

14. extern char * P; different from extern char P [];


1-C traps and defects 1 in the computer classic book series

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.