unbuffer fstream

This is a discussion on unbuffer fstream within the C++ Programming forums, part of the General Programming Boards category; Code: file.rdbuf()->pubsetbuf(NULL,0); Doesn't work here. I've read it is not guaranteed on all platforms. Am I better off using FILE* ...

  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    unbuffer fstream

    Code:
    file.rdbuf()->pubsetbuf(NULL,0);
    Doesn't work here. I've read it is not guaranteed on all platforms. Am I better off using FILE* if I want unbuffered file output on linux?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,607
    I would question why you need unbuffered file output when you already have full control with "flush".

    gg

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Codeplug View Post
    I would question why you need unbuffered file output when you already have full control with "flush".

    gg
    Well, mostly so I do not have to call flush every time.

    Anyway, I dealt with this by using a wrapper that will call flush every time. Just curious (for future reference) if there is a way to set the stream unbuffered to start with.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,607
    There's the unitbuf flag - C++ I/O Flags [C++ Reference]

    Doing it yourself would better.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with fstream, one variabile for write and read
    By Smjert in forum C++ Programming
    Replies: 3
    Last Post: 02-03-2009, 09:19 PM
  2. Fstream. I/O
    By kevinawad in forum C++ Programming
    Replies: 2
    Last Post: 07-07-2008, 09:19 AM
  3. ARGH! fstream errors
    By OttoDestruct in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2004, 10:37 PM
  4. Are fstream and ofstream incompatible?
    By johnnyd in forum C++ Programming
    Replies: 5
    Last Post: 03-19-2003, 11:21 AM
  5. Problems with fstreams.
    By mosdef in forum C++ Programming
    Replies: 7
    Last Post: 06-19-2002, 03:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21