|Other possible sources of performance problems include the read buffer size, and the fact that the C run-time library converts every CR LF line terminator ("\r\n") in the text file to LF ("\n") during the read operation. Perhaps Pelles C uses a larger buffer, and perhaps it reads the file as binary by default? Just speculating because I don't know anything about Pelles C.|
Also, some comments on your function:
int ProcessFile(char* in)
You are not modifying this argument, so why not const char *name?
Why 4097? You are passing 4096 to fgets. It will only write that many characters. You don't need to declare one extra byte.
fh1 = fopen(in,"r");
if(fh1 == NULL)
fgets(line,4096,fh1); // bottleneck
If you are at the end of the file, this will not be detected until AFTER you call fgets. At this point in your program, you will have read PAST the end of the file but you are still inside the while-loop trying to process data that doesn't exist. This while(!feof(fh1)) technique worked in Pascal, but it doesn't work in C. You need to do this:
while (fgets(line, sizeof line, fh1))