From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: read a file backwards Date: 24 Sep 2001 18:04:46 GMT Organization: Cornell University Lines: 46 Sender: asu1 AT cornell DOT invalid (on 128.253.251.163) Message-ID: References: <3BAF4C56 DOT 3F2904BC AT erols DOT com> NNTP-Posting-Host: 128.253.251.163 X-Trace: news01.cit.cornell.edu 1001354686 27237 128.253.251.163 (24 Sep 2001 18:04:46 GMT) X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu NNTP-Posting-Date: 24 Sep 2001 18:04:46 GMT User-Agent: Xnews/4.06.22 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Chris Smith wrote in news:3BAF4C56 DOT 3F2904BC AT erols DOT com: > Hello everyone, > I am working on a small encryption utility program. At one point in the > program I need to be able to read a file backwards. Have I missed > something specific about djgpp, or have I just over looked the obvious? > Below is a sample of the code I am attempting to use: > try the following: #include int main(int argc, char *argv[]) { char c; int i; int myeof; ifstream fin(argv[1], ios::binary); if( fin == NULL ) exit(1); fin.seekg(0, ios::end); myeof = - ( fin.tellg() + 1); for( int i = -1; i > myeof; --i) { fin.seekg(i, ios::end); fin.get(c); cout << c; } fin.close(); return 0; } -- -------------------------------- A. Sinan Unur http://www.unur.com/