20110327-8.3-将输入与输出绑在一起

来源:互联网 发布:淘宝网波西米亚连衣裙 编辑:程序博客网 时间:2024/05/29 18:13
  1. 当输入流与输出流绑在一起时,任何读输入流的尝试都将首先刷新其输出流关联的缓冲区
  2. 如果在调用tie函数时传递实参0,则打破该流上已存在的捆绑
#include "stdafx.h"
#include 
using namespace std;
 
int _tmain(int argc, _TCHAR* argv[])
{
    cin.tie(&cout);//illusstration only:the library ties cin and cout for us
    ostream *old_tie=cin.tie();
 
    cin.tie(0);//break tie to cout,cout no longer flushed when cin is read
    cin.tie(&cerr);//ties cin and cerr,not necessarily a good idea!
 
    cin.tie(0);//break tie between cin and cerr
    cin.tie(&cout);//restablish normal tie between cin and cout
    system("pause");
    return 0;
}
 
原创粉丝点击