[英]How does the scheme below garantees there'll be just one definition for the objects cin, cout, …?
[英]how does the Cin and Cout objects work in a loop
我有這段代碼
int main()
{
char ch;
while (cin >> ch)
cout << ch;
return 0;
}
我在游盪的是cin
在while()
循環中如何工作? 我的意思是,它是否具有內部索引?
輸入數據時,循環將繼續,僅當找到EOF(文件末尾) ctrl + C
(在Windows中) ctrl + D
(在Linux中)時,循環才會停止
當您需要測試很多案例並且不確定是否有多少案例時,這很有用,您可以輸入所需的次數,只有找到文件結尾時程序才會停止!
輸入示例
a
b
c
(ctrl + d)
示例輸出
a
b
c
the program will finish because EOF was found!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.