Going through the K&R's The C Programming Language and I wrote a code for Exercise 1-12 that for all intents and purposes seems to work. However, I became curious how it could be adjusted for more lengthy input that would span multiple lines. The current program I wrote terminates the input as soon as I hit enter. Is there a way to adjust the program so input is only terminated when I desire and not by the newline character? Here's the program I used.
#include <stdio.h>
main()
{
    int c;
    while ((c = getchar()) != EOF)
    {
        if ( c == ' ' || c == '\n' || c == '\t' || c == '-')
            putchar('\n');
        else
            putchar(c);
    }
}
Thanks in advance.
 
     
     
     
     
     
     
    