cin.clear()如何清除输入缓冲区? [英] How does cin.clear() clear the input buffer?

查看:125
本文介绍了cin.clear()如何清除输入缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的阅读, cin.clear()重置标志,但这如何清除输入缓冲区?

From what I have read, cin.clear() resets the flags, but how does this clear the input buffer?

推荐答案

cin.clear()对输入缓冲区没有影响。正确读取后,它会重置 iostate 标志(从技术上讲,用 std :: ios_base :: goodbit )

cin.clear() has no effect on the input buffer. As you correctly read, it resets the iostate flags (technically, replaces their current value with std::ios_base::goodbit)

这篇关于cin.clear()如何清除输入缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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