Thread View: gnu.g++.help
1 messages
1 total messages
Started by Michael.Conner
Tue, 29 Sep 1992 16:00
fstream filbuf problem
Author: Michael.Conner
Date: Tue, 29 Sep 1992 16:00
Date: Tue, 29 Sep 1992 16:00
32 lines
1323 bytes
1323 bytes
I need to get an fstream with known buffer size. I am trying
to do this by getting the filebuf through rdbuf() and then setting
the buffer, using setbuf(char *, int ). I keep getting a bus error
when I try to actually output something. Is this the wrong way to
do this ? If so, shouldn't rdbuf() return a const filebuf *. Is
there a work around for this? Help!
I'm using gcc 2.2.2 on INTERACTIVE UNIX Sys V/386 Rel 3.2
Here's the code:
#include <iostream.h>
#include <fstream.h>
main (){
fstream x;
(x.rdbuf())->setbuf( new char[4096], 4096 );
if (x.fail()) cout << "fail set(1)" << endl;
x.open("somefile", ios::in | ios::out );
if (x.fail()) cout << "fail set(2)" << endl;
cout << "----" << endl;
x << "some output";
cout << "++++" << endl;
}
Here's the results:
----
Bus error - core dumped
--
Michael.Conner@mixcom.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads