From 49891f6bce29843f503b437c84d83cb787ecfa87 Mon Sep 17 00:00:00 2001 From: Zhineng Li Date: Sat, 10 Jan 2026 16:37:39 +0800 Subject: first commit --- ch01/ex09-copy.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ch01/ex09-copy.c (limited to 'ch01/ex09-copy.c') diff --git a/ch01/ex09-copy.c b/ch01/ex09-copy.c new file mode 100644 index 0000000..2303b83 --- /dev/null +++ b/ch01/ex09-copy.c @@ -0,0 +1,21 @@ +#include + +/* 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; + } + } +} -- cgit v1.2.3