• Advertisement
Sign in to follow this  

reading file from certain position

This topic is 4292 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Why not just...

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

To move within file you need call fseek..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement