Hi - This is all very interesting. Just for fun I ran Thaddy's code (reply #6) with a counter added (just to give me some return). I used a 7.5MB text file. As before, the pascal version took about 32 seconds, while the c version was almost instantaneous (~5 sec). I am comparing older-style pascal on purpose, as I am simply interested as to why it is slower, as I see no reason why it should be (as stated by others)...
I hope this is the right area to ask this. I have noticed that reading binary files is very slow compared to other languages, at least using older pascal verbage. As an example this:while not EOF(subject_file) do begin read(subject_file, b); TotalCount := TotalCount + 1; end; is more than 10x slower than equivalent C language. I have wondered about this for years, and finally decided to ask for some input. Does anyone have an ideas about this?
This method is the fastest possible for file reading, and in any op. system.