www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/10/19:09:33

From: Jerzy DOT Witkowski AT ii DOT uni DOT wroc DOT pl (Jerzy Witkowski)
Newsgroups: comp.os.msdos.djgpp
Subject: Bug in `fstream' class
Date: 10 Feb 1997 13:36:36 +0100
Organization: University of Wroclaw
Lines: 50
Sender: jwi AT dadzbog DOT ii DOT uni DOT wroc DOT pl
Message-ID: <x6raion8h7.fsf@dadzbog.ii.uni.wroc.pl>
NNTP-Posting-Host: dadzbog.ii.uni.wroc.pl
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

A friend of mine found a bug in `fstream' class of the `iostream'
library.  The bug makes impossible opening single file for both
reading and writing.  It is present in both 2.00 and 2.01
versions.

The example program is included below.  It produces the following
results:
on Sparc with Solaris 2.4 and gcc 2.7.2:
	[klm/k-m] (correct)
on PC with DOS and Borland C++ 3.1:
	[mlk/m-k] (also correct, I think :-)
on PC with DOS and DJGPP 2.xx:
	[   /   ] (not spaces, but (char)(255), also data file corrupted)

Any suggestions?

============================== program begin
#include <fstream.h>
#define FILENAME "fstr.dat"

void fileCreate (void) {
  ofstream f(FILENAME);
  for (char c = 'a'; c != 'z'; c++) f << c;
} // fileCreate

void fileReadWrite (void) {
  fstream f(FILENAME,ios::in|ios::out);
  f.seekg(10); 
  cout << '[' << (char)(f.get()) << (char)(f.get()) << (char)(f.get());
  f.seekp(11);
  f.put('-');
  f.seekg(10); 
  cout << '/' << (char)(f.get()) << (char)(f.get()) << (char)(f.get());
  cout << ']' << endl;
} // fileReadWrite

int main (void) {
  fileCreate();
  fileReadWrite();
  return 0;
} // main
============================== program end

-- 
Jerzy Witkowski     <Jerzy DOT Witkowski AT ii DOT uni DOT wroc DOT pl>          o       o

University of Wroclaw, Institute of Computer Science         /| |   |/|
Przesmyckiego 20, PL-51151 Wroclaw                            |/|   | |
room: 11, phone: 0048 71 3247360                             /| |/^\| |
phone/fax office secretary: 0048 71 3251271                <__|

- Raw text -


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