C examples for Data Type:char
Prints input one word per line.
#include <stdio.h> int main(void){ int c = 0, linestarted = 0; /*from w w w . j a v a 2 s . c o m*/ printf("Input some characters, then press Ctrl+D.\n"); while ((c = getchar()) != EOF) if (c == ' ' || c == '\t' || c == '\n') { if (!linestarted) { putchar('\n'); linestarted = 1; } } else { putchar(c); linestarted = 0; } return 0; }