Skip to content

Instantly share code, notes, and snippets.

@Syzygies
Created October 28, 2012 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Syzygies/3969330 to your computer and use it in GitHub Desktop.
Save Syzygies/3969330 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv) {
int bread;
char c, buf[256 * 1024];
char *ptr, *end;
FILE *file = fopen("input.txt", "r");
bread = fread(buf, 1, 256 * 1024, file);
while (bread) {
ptr = buf;
end = ptr + bread;
one:
if (ptr == end) goto done;
c = *ptr;
if ((c >= 9 && c <=13) || c == 32) {
++ptr;
goto one;
}
if (c >= 97 && c <= 122) *ptr &= ~32;
++ptr;
two:
if (ptr == end) goto done;
c = *ptr;
++ptr;
if ((c >= 9 && c <=13) || c == 32) goto one;
goto two;
done:
write(1, buf, bread);
bread = fread(buf, 1, 256 * 1024, file);
}
fclose(file);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment