From: boylesgj AT lion DOT cs DOT latrobe DOT edu DOT au (Gregary J Boyles) Newsgroups: comp.os.msdos.djgpp Subject: tellg problem Date: 10 Feb 1997 13:46:37 GMT Organization: Comp.Sci & Comp.Eng, La Trobe Uni, Australia Lines: 95 Distribution: world Message-ID: <5dn8rt$scs@lion.cs.latrobe.edu.au> NNTP-Posting-Host: lion.cs.latrobe.edu.au To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp The following two functions are designed to read in data from a file with the following format : Number of suburbs (integer) Suburb 1 (string) Number of streets (integer) Street 1 (string) Street 2 (string) . . . . Blank line Suburb 2 (string) Number of streets (integer) Street 1 (string) Street 2 (string) . . . . Blank line . . . . The details of each suburb (name and number of streets etc) are stored in a seperate class SuburbC object. The variable File is of type fstream and is a data member of class SuburbListC. It was created via the constructor fstream() i.e. it was an unattached stream. The variable FilePosStreetList is of type long and is a data member of SuburbC. // Reads in the list of suburbs and streets from the file. void SuburbListC::Get() { static StringC EOL,MainDir=Config->GetMainDir(); int I; File.open(MainDir+"streets.dat",ios::in); if (!File) Error->ErrorMessage(NoFile,MainDir+"streets.dat"); else { File>>NumSuburbs>>EOL; SuburbList=new SuburbC[NumSuburbs]; for (I=0;I>Name>>NumStreets>>EOL; *****FilePosStreetList=In.tellg();**** for (I=0;I>EOL; In>>EOL; }