c++ - Data position in file -


at first loaded variables memory @ application start. on time, number of variables became huge don't want anymore. instead retrieving them when needed (using mapped file, story).

at first write variables file. (this repeated many times...)

vector<udtaudioinfo>::iterator = naudioinfos.content().begin(); (;it != naudioinfos.content().end(); ++it)      //i think here should store position data begin in file     //i still need add code that...      //now write variables      fwrite(&it->unitid,sizeof(int),1,outfile);     fwrite(&it->floatval,sizeof(double),1,outfile);      //i think here should store length of data written     //i still need add code that...  } 

but need load variables dynamically, need keep track of stored.

my question be: how can find out current write position? think , hope use keep track on data resides in file.

you can use function ftell() reading or writing variables.

for example, in example code above, find position @ start of each iteration with:

 long fpos = ftell( outfile ); 

when ready return position, can use fseek(). (below, seek_set makes position relative beginning of file.)

 fseek ( infile, position, seek_set ); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -