Created
July 25, 2015 14:50
-
-
Save jesselawson/c44b4d12df9967fdf87d to your computer and use it in GitHub Desktop.
Remove extra blanks from input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int c; | |
int lastc; | |
while((c=getchar()) != EOF) { | |
if(c == ' ') { | |
if(lastc == 1) {} else {putchar(c); lastc = 1; } | |
} else if (c != ' ') { | |
putchar(c); | |
lastc = 0; | |
} else {} | |
} | |
printf("With extra blanks removed: %d\n", c); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment