Question 1

In the previous example, when can the string object s be freed?

-       never

-       when the program terminates

-       after the call to fprintf

-       before the call to fprintf

-       in newline

 

Question 2

(Review) Here we have fixed a subtle bug in previous labs having to do with EOF.  Note that ch is declared to be an int, not a char.  What happens in the three uses of ch within the while loop of newLine?

-       ch and eof are both ints, so the full 32 bits are compared

-       The newline char is zero extended to be an int and compared with ch

-       The low 8 bits of ch are stored in the line array

-       All of the above

 

Question 3

What do we need to do to determine how much storage to malloc to hold the string that we read in?

 

Question 4

When is the storage for the temporary buffer line reclaimed?

-       Immediately

-       When newLine is called

-       When newLine returns

-       In Main

-       Never