c++ std::cin被困在80行输入中

C++ std::cin is stuck at 80 lines of input

本文关键字:80行 输入 std cin c++      更新时间:2023-10-16

这是我的代码

int main() 
{
  int total = 0;
  int count = 0;
  std::cin >> total;

  int arr[4] = {0,0,0,0}; 
  while(count < total) 
  { 
    std::cin>>arr[0]>>arr[1]>>arr[2]>>arr[3];
    count++;
    std::cout<<count<<std::endl;
  }
 return 0;
 }  

所以输入的第一行告诉我在…之后需要读多少行,每行有4个用空格分隔的数字。每当行数超过80(e。g100),然后while循环卡住。我不知道是什么原因导致的问题,我已经尝试了一些事情,如cin.clear(),但他们只是不工作....

Edit: std::cin在格式为10 20 210 10的80行输入后停止读取

Xcode with LLVM不工作…然而,g++使用终端工作....http://melpon.org/wandbox/permlink/UXAMgM4ldn2K2NgU下面的代码可以在我的终端上使用g++,但不能在我的xcode中使用…

是输出卡住了。除非count的输出正在被某些东西读取并消耗,否则最终输出缓冲区将满,cout行将阻塞。