[sclug] C++ Quickie

Tim Sutton t.sutton at reading.ac.uk
Wed Dec 10 10:51:41 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

Tim Sutton
BDWorld Middleware Programmer
- -------------------------------------------------------------------
BiodiversityWorld Project
Centre for Plant Diversity & Systematics
School of Plant Sciences
The University of Reading
Reading, RG66AS, UK

Web     :   www.bdworld.org
Phone  :   +44-(0)118-378-6052  
Email    :   t.sutton [at] reading.ac.uk
(email preferred method of correspondence)
- -------------------------------------------------------------------


More information about the Sclug mailing list