Turn on/off buffering for streams in c++

Use io manipulator ‘unitbuf’ to turn off stream buffering and ‘nounitbuf’ to turn on stream buffering. If ‘unitbuf’ is on the stream object is flushed after every insertion else the stream is not force flushed. For e.g. endl triggers a flush in cases of ‘nounitbuf’. Sample code: fstream fstr( “c://Hello.txt” ); [sourcecode language=”cpp”]cout << unitbuf […]
Continue reading…