I'm trying to run this code on Windows 7 (64-bit, if it matters) after compiling it with GCC. If I declare bufsize as an int, the program freezes and Windows informs me that it's stopped working. If I use #define bufsize 123 it works fine, and it works fine if I replace bufsize with a number myself. What am I missing here?
int main(int argc, char* argv[]) {
char* filename = argv[1];
FILE* problem = fopen(filename, "r");
if (!problem) {
printf("File doesn't exist\n");
exit(1);
}
char* line;
while (fgets(line, bufsize, problem) != NULL) {
printf(line);
}
return 0;
}