曾经一段时间经常会去Google Groups的comp.lang.c小组里逛逛。在那里，『The C Programming Language』(Kernighan&Richie著，以下简称K&R)是被当成神作供起来的，简直就是C语言领域的“圣经”。于是当时慕名下了电子书看了有一半左右，因为e文不好看着非常累，虽然看后感觉挺有收获，但还是放弃了没有看完。后来不知道哪一次脑热买了K&R实体书，过去几年，它一直沉睡在那里。如今，陆陆续续接触到了各种五花八门的编程语言，C语言除了考试和面试反而不怎么用到了，但是没读完这本书却始终觉得人生不完整。于是，强迫自己将它翻完一遍，感觉真的是非常基础，讲得也透彻，我都不知道用什么词汇去形容它的浅显和通俗了。如果入门时授课老师用这本书当教材应该是个不错的选择。
1. Comments may appear anywhere a blank or tab or newline can.
2. printf is not part of C language; there is no input or output defined in C itself. printf is just a useful function from the standard libray of functions that are normally acessible to C programs. printf recognizes %% for % itself. printf uses %f for both float and double.
3. getchar() returns a distinctive value when there is no more input. We can't define a char value to hold the return value of getchar() because char is not big enough to hold EOF in addition to any possible char. Use int instead.
4. A character written between single quotes represents an integer value equal to the numerical value of the character in the machine's character set.
5. With properly designed functions, it is possible to ignore how a job is done; knowing what is done is sufficient.
6. In C, all function arguments are passed "by value." This means that the called function is given the values of its garguments in temporary variables rather than the originals. int is the default return type of function, it could be omitted.
7. An external variable must be defined, exactly once, outside of any funtion.
8. "Definition" refers to the place where the variable is created or assigned storage; "Declaration" refers to places where the nature of the variable is stated but no storage is allocated.
9. Begin variable names with underscore is legal but not recommend, since library routines often use such names.
10. A leading 0 (zero) on an integer constant means octal; a leading 0x or 0X means hexadecimal.
11. String constants can be concatenated at complie time: "hello," "world" is equivalent to "hello, world". char st = "hello, " "world!"; is legal.
12. If not all values are specified in enumerations, unspecified values continue the progression from the last specified value. Names in different enumerations must be distinct. Values need not be distinct in the same enumeration. Enumeration variables offer the chance of checking and so are often better than #define.
13. External and static variables are initialized to zero by default.
14. The % operator cannot be applied to float or double.
15. The increment and decrement operators can only be applied to variables; an expression like (i+j)++ is illegal.
16.Bitwise operators like &,|,^,<<,>>,~ only be applied to integral operands, that is char, short, int and long, whether signed or unsigned.
17. x *= y + 1 means x = x * (y + 1) rather than x = x * y + 1.
18. An bitcount function:
/* bitcount: count 1 bits in x */
int bitcount (unsigned x)
for (b = 0; x != 0; x >>= 1)
if (x & 01)
Declaring the argument x to be unsigned ensures that when it is right-shifted, vacated bits will be filled with zeros, not sign bits, regardless of the machine the program is run on.
19. printf("%d %d\n", ++n, power(2, n)); can produce different results with different compilers, depending on whether n is incremented before power is called.