cplusplus.com
  C++ Library Reference : IOstream Library : streambuf : pubsync
- -
º¯Êý¿â
C++º¯Êý¿â
Cº¯Êý¿â
C++º¯Êý¿â
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
streambuf
· streambuf::streambuf
· streambuf::~streambuf
public members:
· streambuf::getloc
· streambuf::in_avail
· streambuf::pubimbue
· streambuf::pubseekoff
· streambuf::pubseekpos
· streambuf::pubsetbuf
· streambuf::pubsync
· streambuf::sbumpc
· streambuf::sgetc
· streambuf::sgetn
· streambuf::snextc
· streambuf::sputbackc
· streambuf::sputc
· streambuf::sputn
· streambuf::sungetc
protected members:
· streambuf::eback
· streambuf::egptr
· streambuf::epptr
· streambuf::gbump
· streambuf::gptr
· streambuf::pbase
· streambuf::pbump
· streambuf::pptr
· streambuf::setg
· streambuf::setp
virtual prot. members:
· streambuf::imbue
· streambuf::overflow
· streambuf::pbackfail
· streambuf::seekoff
· streambuf::seekpos
· streambuf::setbuf
· streambuf::showmanyc
· streambuf::sync
· streambuf::uflow
· streambuf::underflow
· streambuf::xsgetn
· streambuf::xsputn

-

streambuf::pubsync public member function
int pubsync ( );

Synchronize stream buffer

Calls the protected virtual member sync, which synchronizes the contents in the buffer with those of the associated character sequence, effectively writing any unwritten character in the output buffer to the physical device.

Parameters

none

Return Value

If the function is succeessful, the function returns zero. If it fails, it returns a value of -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 of the file after the first sentence.

Basic template member declaration

( basic_streambuf<charT,traits> )
int pubsync ( );

See also

streambuf::sync Synchronize stream buffer (virtual protected member function)
© Copyright © 2007-2008 ¿áÇÚÍø All Rights Reserved