I've started studying "The ANSI C Programming Language" by Dennis Ritchie and Brian W.Kernighan. So far I've just learned getchar(),putchar(),while, for, if. There is an exercise that I have to do only using what I've learned by now. The above are the only things I know. Here's the exercise as it appears in the book:
Exercise 1-9. Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.
I know C#, Pascal, Objective-C and some Java but I cannot understand how this problem can be solved without using arrays. I know arrays but as the author has not covered arrays yet I assume I must not use them. Arrays are taught in the next chapters.
Implementing Nikolai's solution, as it might be easier to understand in code,
http://ideone.com/LLmBh
If you really want to avoid
bool
, you can just useint
instead.