Skip to content

Instantly share code, notes, and snippets.

@jesselawson
Created July 25, 2015 14:50
Show Gist options
  • Save jesselawson/c44b4d12df9967fdf87d to your computer and use it in GitHub Desktop.
Save jesselawson/c44b4d12df9967fdf87d to your computer and use it in GitHub Desktop.
Remove extra blanks from input
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