To make full use of final long vacation, I decide to read the classical book of C programming book: THE C PROGRAMMING LANGUAGE. Due to its high practical, I will finish every exercises , refer to keys to them and make some analysis. Doing is better than saying, I have finished ex1_8-ex1_11 and have some problems. The whole practice is under Fedora 14.
First of all, I found that the color of keyword will not be displayed when missing the proper suffix. For example, if I use vim ex1_8 instead of vim ex1_8.c, the keywords wil not be properly colored. The version of my VIM is 7.3.56 and I do not agree that filenames take effect under Linux circumstanes.(TBS.1)
Then, this problem is from ex1_9 on the page 20. The question is that wirite a program to copy its input to its output, replacing each string of one or more blanks by a single blank. I decided to use an array variable temp[] to save data from getchar(), to give data to putchar(). The first part about getting data is below:
while(done == 0){
src = getchar();
temp[count] = src;
if(src == EOF)
done = 1;
count++:
}
......
When typing Enter or Ctrl+D, I found that the program just execute its loop without checking the judgment 'done’. If I change the whole program into a clear type, the probelm will be solved:
......
while((src = getchar()) != EOF)
......
I think the problem is the misunderstanding of the process of getchar(). With further learning, I will find the answer.(TBS.2) Another problem is that some messy code will appear if I remove the particular number of the definition of array variable, like char temp[]={} instead of temp[100]={};(TBS.3)
The last problem is from exe1_10. Write a program to copy its input to its output, replacing each tab by \t, each back by \b, and each backslach by \\. Even the reference answers can not display the trace of backslach(TBS.4)