Hi all,

I have a file in which each line is a tab seperated array of floats. And i have close 200,000 lines in that file. Now, I wanted a fast way to read this file.. Reading it line by line was too slow, so I wanted to try and read in chunks of the file (Say 100 lines at a time) and extract out the values from that in memory.

To do this, I first wanted to find the memory size in the file taken up by 1 line. Then I could fread(100xsizeof 1 line).. But when I tried to do this, i found that each line had a different size on the file. I can understand that if I read one line of the file into a string in my program and try to find the string length, it would be different for each line because a float no. like 234.56 would take up 6 chars while 23.56 would only take up 5 chars.

But even when I tried to check how much distance the file pointer had moved after 1 fgets().. [ftell(fp)].. I still get different sizes for different lines!. So my question is, how exactly is data stored into a file? If i try to store a float, is it converted into a string when it is being stored in a file? Should 200 floats always occupy the same memory space irrespective of what the value of the float is?

And lastly, to go a little bit off topic, if anyone has any pointers on whether I am going the right way in trying to read my file in the quickest possible way, I would really appreciate your advice..

Thanks in advance,

Avinash