CS360: Exam 1: 10/22/97. Answer to Question 2


A

This simply prints out the words on each line backwards:
P S J
HBP
P M K

B

Since you didn't call strdup(), this will put three nodes into the dlist, all of which point to s:
K M P
K M P
K M P

C

Yucky code. It will first copy put the integer 3 into the first 4 bytes of buffer. The next three bytes will be "JIM". Then iptr will be set to buffer+7, which is not a multiple of 4, so the line
   *iptr = strlen(s2);
will cause a bus error. This is subtle, but typical of the kind of codes that cause bus errors.