streambuf::pubsync
int pubsync ( );
streambuf
  cplusplus.com  

Synchronize stream.
  Calls protected virtual member sync.
  The standard behavior of member function sync in derived stream buffer classes is to syncronize the stream buffer with any external associated device (like the file in file streams).

Parameters.

none
 

Return Value.
  If the function succeeds it shall return 0, otherwise -1.

Example.

// pubsync member
#include <iostream>
#include <fstream>
using namespace std;

int main () {

  streambuf * pbuf;
  ofstream ostr ("test.txt");  

  pbuf = ostr.rdbuf();

  pbuf->sputn ("First sentence\n",15);
  pbuf->pubsync();
  pbuf->sputn ("Second sentence\n",16);

  ostr.close();

  return 0;
}
In this example, the buffer is synchronized with the content file of the file after the first sentence.

Basic template member declaration ( basic_streambuf<charT,traits> ):
int pubsync ( );

See also.
  streambuf class


© The C++ Resources Network, 2001