You understand it well enough (the problem that is) so it is all in the implementation now. Basically you want to define two states (a state machine), 'in' a word, and 'outside' of a word. I think that is maybe the approach your were attempting. Start by assuming that you are
not in a word, and get a character. Test it. If it is a ' ' or a '\t', ignore it, and move on to the next character. Repeat. When you get a non-whitespace character, now you are 'in' a word (or 'out' of a space, if you like). Change the state to reflect that. Print that character. Get the next one. Test it. If it is not whitespace, print it. Do this until you get to a whitespace. When you get to a whitespace, print a ' '. Then change the state to 'out', and discard all the following whitespace (if any) characters. Continue on like this until you reach EOF.
Exercise 1-12 is somewhat similar, except that it writes one word per line. Basically it inserts '\n' instead of ' '. Have a look at
this for an example of what I described in the paragraph above. Just keep in mind that it is not the same program, but does has some pertinent ideas. If you want some good solutions to the exercises (sometimes it doesn't hurt to have a look after you have tried what you can to solve the problem), Richard Heathfield keeps a site with some
here.