summaryrefslogtreecommitdiff
path: root/ch01/ex09-copy.c
blob: 2303b8346155abe7719c945714ba1e5b2505ee91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>

/* merge consecutive blanks */
int main()
{
	int c, b;

	b = 0;
	while ((c = getchar()) != EOF) {
		if (c != ' ') {
			putchar(c);
			b = 0;
		}

		if (c == ' ') {
			if (b == 0)
				putchar(c);
			b = 1;
		}
	}
}