reading file from certain position

Started by
3 comments, last by jazztuffy 17 years, 9 months ago
hi guyz, Iam dumpin g a matrix into a binary file. And i am reading it. I need to take sinfle element at a time and read it. If there is any way i can read entire matrix at a time please lemme know. Else how can i start readin the file from certain position like the number width is abt 7 charecter. so hw can i go abt starting from 8 charecter for next element. Please guide me thank you
Advertisement
Why not just...

fread (buffer,1,sizeof(MyMatrixClass),pFile);

To move within file you need call fseek..

Quote:Original post by Anonymous Poster
Why not just...

fread (buffer,1,sizeof(MyMatrixClass),pFile);

To move within file you need call fseek..


This will work as long as MyMatrixClass does not have any virtual functions or inherit from a class that has virtual functions. If it did, then the compiler will add a hidden pointer to the class to reference the vtable.
<a href="http://www.slimcalcs.com>www.slimcalcs.com
Yeah I actually added that as an edit but it didn't let me add it as I was logged in as anon when I posted... :)

If you need to stream memory images of classes that have virtual function you have to invoke the in-place new constructor... (and make sure your c'tor doesn't overwrite any of the streamed values).

Also if your matrix class DOES have virtual functions then you are in for a world of hurt anyway :P
thank you guyz..i am able to run the program using fseek..

This topic is closed to new replies.

Advertisement