I downloaded the examples from the book, and they work nicely writing a little text in the terminal window, i started it in, and they should for you as well. Did you try running them from a terminal window or by clicking on an icon on the desktop? In the later case, im not entirely sure, where the text would go. I suspect, the programs would work quite nicely, but you just dont see the output. What do you mean by getting an empty text file using "gcc -o ...."?
Yours sincerely,
Bjorn