does anybody have any examples of reading from a variable length file using fread, Im using something like this
fread(&sInputRec, Len,1, fpInput);
but the problem is i dont know the length for each record.
Thanks
I'm assuming that the records ahve some sort of delimiter
Option 1
Read the whole file into a buffer. i.e.
stat the file
malloc of enogh memory
read in the file
use something like strtok to break up the file into records.
Option 2
Create a buffer big enough to handle the biggest record. Read in the file byte at a time int the buffer until the delimiter is met.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.