delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/21/01:10:18

Message-ID: <19990521050908.31888.qmail@hotmail.com>
X-Originating-IP: [202.54.87.102]
From: "chirayu krishnappa" <kchirayu AT hotmail DOT com>
To: djgpp AT delorie DOT com
Subject: need workaround
Date: Thu, 20 May 1999 22:09:08 PDT
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

The following code fails to work. (using GCC 2.8.1 - its *cool*)

#include <iostream.h>
#include <fstream.h>

int main() {
  fstream f("test");
  f.peek();
  cout << f.tellg() << "  " << (char) f.get();
}

The file "test" contains the string ABCD.

The program incorrectly displays "1 B" instead of "0 A". (This behaviour
happens if peek() is called as above).

Anyone can suggest a workaround? (get() followed by putback() does
not help).





______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019