好的,所以我在我的教科书中遇到了这个代码片段,它应该与用户输入的每个其他字符相呼应。现在,我理解了所有其他字符部分,但我在使用 cin.get() 时遇到了困难。我明白为什么第一个 cin.get() 在那里,但为什么它也在循环内?我猜我没有完全掌握输入流的性质......
编辑:它刚刚点击...我是个白痴。感谢您清除它。
char next;
int count = 0;
cout << "Enter a line of input:\n";
cin.get(next);
while (next != '\n')
{
if ((count%2) == 0)
cout << next;
count++;
cin.get(next);
}
提前致谢!