set1 of study questions: ------------------------------------------------------------------------ 1. you should be able to construct a makefile for 3 C files that would allow incremental compilation. Given that -- how might this makefile be improved? target: foo cc -o foo a.c b.c c.c 2. given the following program, what does gdb do about the code in the #ifdef (assume that code is NOT compiled) cc -g -o foo foo.c main() { #ifdef GARP printf("hi from garp\n"); #else printf("hi from not garp\n"); #endif } In other words, if you use gdb, will it see the #ifdef GARP is true part of the code? (try it). The point is: what happens when gdb gets to that code. 3. try something like % gcc -E foo.c (or cc depending on where you are of course) where foo.c is: #include main() { printf("shijie, ni hao\n"); } What does this do? 4. what is wrong with this snippet of code (very common bug -- try not do it) fprintf("hi world\n"); 5. what would the following program snippet do? char buf; read(0, &buf, 1); write(1, &buf, 1); 6. is this buggy or not? int x; scanf("%d", x); printf("%d", x); If so, what is the problem and how do you fix it? Answers to the list are ok for any of these. questions about assignment 1: ----------------------------