Sample Midterm Answers #12


    1. /usr/bishop/passwd+/misc/root.c
    2. /usr/holly/DMS/schedule
  1. from > FROM.OUT
  2. grep '<stdio.h>' *.c
  3. rm ./-i or rm -- -i
  4. The path variable contains a list of directories. When a user types a command that does not contain a "/", the shell searches each directory in that list for the command, and executes the first such file it sees.
  5. Beause ANSI C does not specify the order of evaluation of function argument, any of the following outputs are possible:
    1. x = 5, a = 1, b = 4, c = 6
    2. x = 1, a = 0, b = 5, c = 6
    3. x = 1
    4. x = 0
    5. x = 5
    6. x = 3, dx = 3.2
    7. x = 0
  6. n = -123
    1. This program compiles correctly. It may give a warning because p is uninitialized when it is used.
    2. When fgets tries to store the line beginning at the address in p, an error occurs. Either the input line is stored at a random memory location, or (more likely) the program terminates abnormally. The problem is that p is uninitialized.