Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在阅读 k&r 时,我遇到了以下示例
#include<stdio.h> int main() { int c; while((c=getchar())!=EOF) { putchar(c); } printf("hello"); }
疑问1:当我在我的系统上输入字符 ctrl+z(EOF) 时。o/p 是你好 ,但是当我输入 abcdef^Zghijk 之类的字符串时, o/p 是 abcdef->(包括箭头)并等待用户输入 i/p 而不是终止循环并打印你好..
ctrl+z不是EOF,它只是告诉您的终端关闭流的一种方式。
ctrl+z
在 Windows 系统上,您需要将 写ctrl+z为行的第一个字符,否则终端将其视为普通字符。