What is considered as EOF in stdin? [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-11 09:47:27

问题


My Visual Studio still awaits input even after I keep entering a newline.

For example:

while ((c = fgetc(stdin)) != EOF)
{
   // do something
}

What should I enter that sends EOF to Visual Studio?


回答1:


You can send an EOF with CTRL+D (for Linux) or CTRL+Z (for Windows) systems.

To elaborate, when fgetc() is waiting for an input from empty stdin, this key combination will simulate the EOF. In case, the stdin is not empty, you have to use the key combination twice (once to help flush the stdin, another to actually send the EOF).



来源:https://stackoverflow.com/questions/41023443/what-is-considered-as-eof-in-stdin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!