[sclug] Quick C++ question

Tim Sutton tim at linfiniti.com
Wed Dec 10 10:38:04 UTC 2003


Hi All

Just a quickie- hopefully someone wont mind helping out ?

I am trying to persist the place where a file is open (the 'data' file). 
Basically I am getting an fpos_t of the current place that I am in the data 
file and writing it to another file (my 'bookmark' file). When I read the 
position back from the bookmark  file and want to restore my position in the 
data file, fscan it from the bookmark file and get it as an int. How do I 
convert the int back to an fpos_t so that I can use it to set the filepos?

The above is a bit of a simplification of what I am actually trying to do - 
which is to build a vector of all the bookmarks in the file as shown in the 
snippet below.

Basically it is the static_cast<fpos_t>(&myCurrentMarkerInt) which doesnt work 
and I am trying to figure out what I should replace that with.


    else  //we managed to open the blockmarkers file so just read them in from 
there
    {  
    cout << "FileReader::getBlockMarkers reading markers from cache file " << 
endl; 
      int myCurrentMarkerInt=0;
      do 
      {
        fscanf (myBlockMarkersFilePointer, "%i", &myCurrentMarkerInt);
        dataBlockMarkersVector.push_back(static_cast<fpos_t>(&myCurrentMarkerInt));
      }    while (!feof(myBlockMarkersFilePointer)) ;
      
       fclose(myBlockMarkersFilePointer);
       return &dataBlockMarkersVector;
    }

Many Thanks

Tim
-- 
Get my public keys from:

http://tim.suttonfamily.co.uk/modules.php?name=Content&pa=showpage&pid=2


More information about the Sclug mailing list