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>
- int main()
- {
- int flag = 0, c;
- while ((c = getchar()) != EOF) {
- if (c == ' ') {
- if (flag == 0) {
- putchar(c);
- flag = 1;
- }
- } else {
- putchar(c);
- flag = 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment