8.1.3 管理输出缓冲

    xiaoxiao2024-11-01  80

    书中页数:P282 代码名称:buf.cc

    #include <iostream> using std::endl; using std::flush; using std::ends; using std::unitbuf; using std::nounitbuf; using std::cout; int main() { // writes hi and a newline, then flushes the buffer cout << "hi!" << endl; // writes hi, then flushes the buffer; adds no data cout << "hi!" << flush; // writes hi and a null, then flushes the buffer cout << "hi!" << ends; cout << unitbuf; // all writes will be flushed immediately // any output is flushed immediately, no buffering cout << "first" << " second" << endl; cout << nounitbuf; // returns to normal buffering return 0; }
    最新回复(0)