The features listed below may not be surprising, and some are interesting.
1) a[2] equivalent to 2[a]
"AABBCCDD" [5] is equivalent to 5["AABBCCDD"]
This attribute can be used for arrays, pointers, strings, but not for variable definitions. K&r C Programming Language 217 pages are described here.
2) Two yuan, ternary compound character
Http://en.wikipedia.org/wiki/Digraphs_and_trigraphs
string literal value??! will be considered |, so be careful when two question marks appear in the string at the same time. Binary compound characters are introduced in C99, as follows: equivalent to [
3) Duff ' s Device
Http://en.wikipedia.org/wiki/Duff%27s_device
The feature is that the switch and the while interleaving appear. Code Similar
4) The same name
There are detailed explanations in "C Traps and defects".
5) a[i++]= I;
This seems to be dependent on a particular compiler implementation, and I xcode the results of the experiment to first assign value to A[i] and then manipulate i++. This kind of code must be careful. If you're doing code review find ++– appearing in other expressions or as parameters, be sure to immediately move it out as a separate statement, carefully sailing the ship.
6) sizeof
sizeof (x), x can be an expression or type name, if it is an expression, not an operation, int x = 1; size_t sz = sizeof (x + +); x does not increase. T *p = NULL; p = malloc (sizeof *p); P did not mention the collar, and k&r the holy book.
sizeof unary-expr; sizeof (typename); a unary expression can be without parentheses, which is mentioned in the grammar section of the holy book. such as size_t f = sizeof 99;
7 macro definition to be careful
For example: #define FOO (a,b) (a+b)/(1-A) If you call Foo (bar++,4) This way, two more times, of course, it's very clear to expand the macro.
Resources:
http://www.steike.com/code/useless/evil-c/
"C Traps and defects"