Print input one word per line (K&R 1-12 exercise) attempt I'm currently trying to learn C from the K&amp;R book, reading through and attempting the exercises. I came across exercise 1-12 yesterday and was a little stumped but managed to complete it. I was wondering if someone on here would help me improve it, and also guide me on how to approach testing something like this too.

The exercise is to write a program which "prints input one word per line".

#include &lt;stdio.h&gt;

#define TRUE 1
#define FALSE 0

int main(){

    int c, previous_space;

    previous_space = FALSE;
    while ( (c = getchar()) != EOF ){
        if ( c == ' ' || c == '\n' || c == '\t' ){
            if ( previous_space == FALSE ){
                putchar('\n');
            }
            previous_space = TRUE;
        }
        else{
            putchar(c);
            previous_space = FALSE;
        }
    }
    return 0;
}
A few points to consider.


C99 added an actual Boolean type, named _Bool, with constants name _True and _False. By including &lt;stdboolh.h&gt;, you get aliases for those spelled bool, true and false. So unless you need to continue using C89, you might consider using these instead of defining your own names and such.
When you have a value that's conceptually Boolean in nature (e.g., your previous_space) I'd treat it as a Boolean, so to test if it's false, I'd prefer to use if (!previous_space).
Rather than explicitly checking for every possible white-space character in-line, I'd prefer to move that check into a separately little function of its own. Only this is such a common requirement that the standard library already provides isspace, so (at least in real code) it's generally preferred to #include &lt;ctype.h&gt;, and us that (but the book probably hasn't introduced this yet, so I wouldn't worry about it a whole lot just yet).