在 Windows 7 上遇到 EOF 问题

2024-03-31

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.

预先感谢您的任何帮助。


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.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Windows 7 上遇到 EOF 问题 的相关文章

随机推荐