C examples for Data Type:char
Copy its input to its output, replacing each string of one or more blanks by a single blank.
#include <stdio.h> int main(void){ int c, blank_recieved = 0; //from w w w . ja va 2 s . c o m printf("Input some characters, when you finishes, press Ctrl+D.\n"); while ((c = getchar()) != EOF){ if (c == ' ') { if (!blank_recieved) { blank_recieved = 1; putchar(c); } } else { blank_recieved = 0; putchar(c); } } return 0; }