Having troubles with EOF on Windows 7

本小妞迷上赌 提交于 2019-11-27 04:48:43

问题


I'm currently learning C with K&R and I'm having a hard time sending EOF simulation through cmd. I was trying Ctrl + Z which did nothing.

In some cases Enter is doing the work and in other cases nothing does it.

Thanks in advance for any help.


回答1:


Assuming you're on Windows, the situation is that you basically have to do the ctrl+Z at the beginning of a line -- i.e., you have to have hit enter, then do the ctrl+Z, then (depending on how the input is being read) possibly enter again.

You can also use F6 to signal the end of the input. At least in most cases, this will work even when/if it does not immediately follow an enter.

Unfortunately, Windows provides enough different ways and modes to read input, that it's a little hard to state a whole lot with absolute certainty unless we know the compiler you're using (or, more specifically, the standard library) as well as the exact code you've written. Under normal circumstances, just hitting enter should not be detected as end of file, but your code could be treating an empty line as the end of input.




回答2:


In a Windows 7 console window, I had success pressing F6 followed by Enter. F6 produces the end-of-file ^Z symbol at the command prompt.

Ctrl+Z causes the console window to quit execution, not only the user program.



来源:https://stackoverflow.com/questions/10589637/having-troubles-with-eof-on-windows-7

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