Exercise 4-7. Ungets function