원하는게 이런 동작임?

http://codepad.org/MVR2G9Ks

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { if(argc != 2) { return 0; } FILE *fp = fopen(argv[1], "r"); if(!fp) { return 0; } long *arr = malloc(sizeof(long) * 10000000), n = 0, cnt = 0, buf = 0, c; if(!arr) { return 0; } memset(arr, 0, sizeof(long) * 10000000); printf("Reading "); puts(argv[1]); while((c = fgetc(fp)) >= 0) { if(c >= '0' && c <= '9') { buf = buf * 10 + c - '0'; ++cnt; } else if(c == '\t') { if(cnt == 7) { if(!arr[buf]) { ++n; } ++arr[buf]; } cnt = buf = 0; } else if(c == '\n') { cnt = buf = 0; } else { cnt = 8; continue; } } printf("Total number of GOs : %ld\n", n); while(1) { printf("Enter GO to find : "); scanf("%ld", &buf); if(buf < 0 || buf >= 10000000) { break; } printf("%ld GO:ld were found.\n", arr[buf], buf); } free(arr); fclose(fp); return 0; }