There are a few things wrong with this. I recommend that you read a tutorial on concurrency.
1: No synchronization
Each of your threads modifies the same value, but you can't guarantee the order in which your code runs. What will happen when
*f
is changed by a different thread in the middle of another's
fread()
call? You're not locking access to
*f
or anything else shared among threads so you're suffering from race conditions.
2: Reading the same file most likely can't be parallelized effectively
See
http://stackoverflow.com/a/10625178
3: Each of your threads attempts to read the entire file
Concurrency is fundamentally a performance hack. The idea is to distribute work among multiple "workers", so that a job gets done faster. However, not every task is suited to having more workers thrown at it.
You are trying to read the entire file in every thread. Barring the hardware issue which makes this all pointless, a better idea would be to have each thread read a different, equally-sized part of the file, storing it in the appropriate place in a single buffer.
The main program would start each thread and then wait for all of the threads to complete their task (perhaps in parallel), and then use the buffer once it was finished being modified. If you tried this, you should have each thread open the file, so that you don't need to wait for all the other threads to be finished with the same file handle before you take over.
If you are writing C++ code (it doesn't look like it), then it would be a good idea to use the standard C++11
<thread>
library if it is available to you.