1) fgets() reads the file one line at a time... got 25000 lines... use a loop.
Originally Posted by rac1
2) Nobody reads files character by character... that's just slow and silly
3) If the file is already open why on earth would you close it and re-open it,
4) If you did #3, why wouldn't you check if it actually opened?
5) if you want to know how big a file is...
6) In c you don't cast the return value of malloc()... if your compiler complains it's in C++ mode.
size = ftell(file);
7) Your routine is horridly inefficient since it has to read the file twice... character by character, no less.
8) if you simply want to read the whole file into memory...
char *buffer = malloc(size);