1-9
Quest: page 20
- write a program to copy its input to its output, replacing eah string of one or more blanks by a single blank.
trim duplicate whitespaces
#include <stdio.h>
#include <stdlib.h>
int main() {
int c;
int blank = 0;
while ((c = getchar()) != EOF) {
if (c == ' ') {
blank++;
} else {
blank = 0;
}
if (blank == 0 || blank == 1) {
putchar(c);
}
}
}