使编译器不自动刷新缓冲区 [英] make the compiler not to automatically flush the buffer

查看:30
本文介绍了使编译器不自动刷新缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么下面的代码不会阻止编译器自动刷新缓冲区?

Why does the below code not stop the compiler from flushing the buffer automatically?

cout.sync_with_stdio(false);
cin.tie(nullptr);
cout << "hello";
cout << "world";
int a;
cin >> a;

输出:

helloworld

我使用的是 Visual Studio 2012 Ultimate

I'm using Visual Studio 2012 Ultimate

推荐答案

AFAIK,只要实现喜欢就可以刷新流,即不能保证在插入操作后刷新流.但是,您可以使用这些操纵器之一来确保您的流被刷新(这些是我唯一知道的,所以如果有人知道其他人,请发表评论):

AFAIK, the stream can be flushed whenever the implementation likes to do so, i.e. there's no guarantee that the stream will be flushed after an insert operation. However, you could use one of these manipulators to ensure your stream gets flushed (these are the only ones I know of so if someone is aware of others, please comment):

这篇关于使编译器不自动刷新缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆