C++ ios Library - Nountibuf Function


Advertisements

Description

It is used to clears the unitbuf "format" flag for the str stream. When the unitbuf flag is not set, the associated buffer is not forced to be flushed after every insertion operation.

Declaration

Following is the declaration for std::nounitbuf function.

ios_base& nounitbuf (ios_base& str);

Parameters

str − Stream object whose format flag is affected.

Return Value

It returns Argument str.

Exceptions

Basic guarantee − if an exception is thrown, str is in a valid state.

Data races

It modifies str. Concurrent access to the same stream object may cause data races.

Example

In below example explains about std::nounitbuf function.

#include <ios>
#include <fstream>

int main () {
   std::ofstream outfile ("test.txt");
   outfile << std::unitbuf <<  "Test " << "file" << '\n';
   outfile.close();
   return 0;
}
ios.htm
Advertisements