1234567891011121314151617181920212223242526 |
- /*
- * Exercise 1-9. 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>
- #include <stdbool.h>
- main()
- {
- int c;
- bool in_space = false;
- while ((c = getchar()) != EOF) {
- if (c == ' ') {
- if (in_space)
- continue;
- else
- in_space = true;
- } else
- in_space = false;
- putchar(c);
- }
- }
|