[C++]输入停止符 Input Stop Signal

在OJ/Project中,可能会遭遇“读取直到无输出为止”的要求。
C++中,cin提供了输入停止符eof(endof file)用以标记输入结束。
对应键盘输入时,Windows下的ctrl+z回车,和Linux下的ctrl+d回车。我们可以用对应按键进行调试。

应用场景案例:
要求“you must continue reading lines until there is no more input.”

使用案例:

while(!cin.eof()){
    //code
}

When coding in OJ or practical practice,  we might face up with somerequirement like "reading until no input".in C++, cin provides a function eof (stands for end offile) to notify the end of the input, which corresponding to"Crtl+Z" and enter in Windows or "Ctrl+D" and enter inLinux from keyboard input. We can use these hotkeys for debugging.

Senerio case:
Require that "you must continue reading lines until there is no moreinput."


Using Example

while(!cin.eof()){
    //code
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值