cin.clear()重置输入流

cin.get()锁住屏幕直到获取输入

while(cin)

cin.get(ch) 方法返回的是一个cin对象,istream类提供了可以将istream对象转换为bool

当cin出现在需要bool地方,eg:while的测试条件中,将cin对象转换为bool的方法自动调用

如果最后成功,转换bool为true

while(cin)  //while input is successful

while(!cin.fail()) or while(!cin.eof())

while (cin.eof == false) or while (cin.fail != true) 都是表示没有读取到Eof

 

相关文章:

  • 2021-09-19
  • 2022-12-23
  • 2021-05-18
  • 2021-08-14
  • 2021-10-07
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案