To: djgpp AT delorie DOT com (djgpp mailing list), 71101 DOT 1702 AT compuserve DOT com (Steve Heller) Subject: DJGPP 2.01 C++ I/O problem Date: Mon, 22 Sep 97 05:31:56 GMT Message-ID: From: cbalciza AT mail DOT dntis DOT ro Precedence: bulk Problem: - (existing) file content discarded when trying to (DJGPP C++) read and write. Borland C++ works fine. Purpose: - updating records into an existing database Goals so far: - works if using C style fopen with 'r+' - works if using C++ style fopen in Borland C++ - fails if using C++ style in DJGPP ifstream f("test.txt", ios::nocreate | ios::in | ios::out | ios::binary); IDE: -RHIDE & DJGPP 2.01 using the following switches: gcc -g -c test.cc -o test.o gcc -o test.exe test.o -liostr Input file test.txt containing 42 bytes as follows: abcdefghijklmnopqrst 12345678901234567890 Expected output: kjihgfedcbalmnopqrst 12345678901234567890 Actual output (DJGPP): GARBAGE. File content is discarded first, then it reads nothing and writes it back. Program: // test program #include #include #include int main(void) { fstream f("test.txt", ios::in | ios::out | ios::binary); if (!f) { cout << "cannot open file" << endl; return 1; } long e,i,j; char c1,c2; e=10; for (i=0, j=e;i