public
Created

  • Download Gist
gistfile1.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#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;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.