2005年10月23日

Code Reading Skills

Before some days, I bought the book Code Reading.
There was an English edition of it. http://lingix.gro.clinux.org/pub/codereading.chm You can read it.

I began to read it. At the beginning of Chapter 2, there was a analysis of echo command in Unix. One nice example of strcmp was a macro about it:
#define STREQ(a, b) (*(a)==*(b) && strcmp((a), (b)) == 0)
It was a nice realization of strcmp. Can you analysis its beauty?

There was another hint for programming. You should check the return value of printing to file. Maybe it was the end of the file length limit. So you can not write the file again.

The two hints were very nice to me. I liked to read it.

没有评论: