Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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>
- main() {
- int c, pc;
- /*
- * set the previous character to anything
- * other than blank
- */
- pc = 'A';
- while ((c = getchar()) != EOF) {
- if (c == ' ' && pc == ' ')
- ;
- else {
- putchar(c);
- pc = c;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment