Page 20

Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.

#include <stdio.h>

int main()
{
	int c, prev;

	while ((c = getchar()) != EOF) {
		if (c != ' ' || prev != ' ') {
			putchar(c);
		}
		prev = c;
	}
}