C: fread to read a file line by line until the end
Im having trouble getting fread to work the way i want it to. I have a long text file 500,000+ lines of text, that i want to read in line by line, until the end of the file. At the moment, my code looks kinda like this
fread(buffer, sizeof(buffer), 1, dataFile);
dataFile is correctly opened.
Basically the problem i get is that it will read in the first 35,000 lines or so, and then stop, like it has run out of memory space or something.
there are 122 characters on each line of the text file.
Can anybody help me with this?
also, how would i go about telling fread to only read in say, the first 5,000 lines? would it just be a matter of keeping track of an incrementing int in a loop?