Windows中的EOF [英] EOF in Windows
问题描述
我是C初学者,我正在尝试执行以下代码来自
K& R书:
main(){
double nc;
for(nc = 0; getchar()!= EOF; ++ nc );
printf("%0.f\ n",nc);
}
我正在运行一个Win2k操作系统,这是一个控制台应用程序。我应该键入什么来获取getchar()中的EOF值并获取程序
正常终止?在UNIX中是CTRL + D但它不能用于
Win2k。
谢谢,
Mazen
Hi,
I am a C beginner and I am trying to execute the following code from
K&R book:
main() {
double nc;
for(nc =0; getchar() != EOF; ++nc);
printf("%0.f\n", nc);
}
I am running a Win2k OS and this is a console application. What should
I type to get the EOF value in getchar() and get the program to
terminate normally? In UNIX that is CTRL+D but it''s not working with
Win2k.
Thanks,
Mazen
推荐答案
" Mazen S. Alzogbi" <毫安********* @ alzogbi.name>在消息中写道
news:51 ************************** @ posting.google.c om ...
"Mazen S. Alzogbi" <ma*********@alzogbi.name> wrote in message
news:51**************************@posting.google.c om...
我是C初学者,我正在尝试执行以下代码来自K& R书:
请注意,K& RC是非标准的。我们试着在这里坚持使用标准的
代码(尽管K& R(第2版)仍然是一本强烈推荐的关于C的书)。我建议您使用符合标准的代码,因为我的更正和补充表示
:
#include< stdio.h>
main( ){
int main()
double nc;
for(nc = 0; getchar()!= EOF; ++ nc);
printf("%0.f\ n",nc);
返回0;
}
我正在运行Win2k操作系统,这是一个控制台应用程序。我应该键入什么来获取getchar()中的EOF值并让程序正常终止?在UNIX中是CTRL + D但是它不能用于Win2k。
Hi,
I am a C beginner and I am trying to execute the following code from
K&R book:
Note that K&R C is nonstandard. We try to stick to standard
code here (although K&R (2nd ed) is still a highly recommended
book on C). I suggest you use standard compliant code, as
indicated by my corrections and additions:
#include <stdio.h>
main() {
int main()
double nc;
for(nc =0; getchar() != EOF; ++nc);
printf("%0.f\n", nc);
return 0;
}
I am running a Win2k OS and this is a console application. What should
I type to get the EOF value in getchar() and get the program to
terminate normally? In UNIX that is CTRL+D but it''s not working with
Win2k.
这不是真的在这里,因为它''关于你的
操作系统的问题,而不是C语言。
我没有使用过Win2K,但它的大多数前辈和DOS,其中
EOF用键盘上的CTRL + Z表示。您可能会或可能不会
也需要按Enter键。在CTRL-Z之后。如果这不起作用,
你需要检查你的操作系统文档,或者在Windows
组中询问。
-Mike
This isn''t really topical here, as it''s a question about your
operating system, and not the C language.
I haven''t used Win2K, but most of its predecessors and DOS, where
EOF is indicated from the keyboard with CTRL+Z. You may or may not
also need to press "Enter" after the CTRL-Z. If that doesn''t work,
you''ll need to check your OS documentation, or ask in a Windows
group.
-Mike
ma ***** **** @ alzogbi.name (Mazen S. Alzogbi)写道:
ma*********@alzogbi.name (Mazen S. Alzogbi) wrote:
我是C初学者,我正在尝试执行以下代码来自K& R书籍:
添加以下行:
#include< stdio.h>
main(){
更好:
int main(无效){
double nc;
for(nc = 0; getchar()!= EOF; ++ nc);
printf("%0.f\ n",nc);
添加:
返回0;}
我正在运行Win2k操作系统,这是一个控制台应用程序。我应该键入什么来获取getchar()中的EOF值并让程序正常终止?在UNIX中是CTRL + D但是它不能用于Win2k。
Hi,
I am a C beginner and I am trying to execute the following code from
K&R book:
Add this line:
#include <stdio.h>
main() {
Better:
int main(void) {
double nc;
for(nc =0; getchar() != EOF; ++nc);
printf("%0.f\n", nc);
Add:
return 0;}
I am running a Win2k OS and this is a console application. What should
I type to get the EOF value in getchar() and get the program to
terminate normally? In UNIX that is CTRL+D but it''s not working with
Win2k.
< Off-topic>
在行的开头输入Ctrl-Z * *。
< /关闭主题>
问候
- -
Irrwahn Grausewitz(ir*******@freenet.de)
欢迎来到clc: http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list: http://www.faqs.org/ faqs / C-faq / faq /
clc OT指南: http://benpfaff.org/writings/clc/off-topic.html
<Off-topic>
Enter Ctrl-Z *at the beginning of a line*.
</Off topic>
Regards
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc: http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc OT guide : http://benpfaff.org/writings/clc/off-topic.html
>注意,K& R C是非标准的。我们试着在这里坚持使用标准的
> Note that K&R C is nonstandard. We try to stick to standard
代码(尽管K& R(第2版)仍然是一本关于C的强烈推荐的书)。我建议您使用标准兼容代码,如我的更正和补充所示:
-Mike
code here (although K&R (2nd ed) is still a highly recommended
book on C). I suggest you use standard compliant code, as
indicated by my corrections and additions:
-Mike
您好Mike,
感谢您的帮助。 Ctrl + Z就是诀窍。我正在阅读K& R的第二版
版本,我认为短语ANSI C Compliant在
封面意味着这是标准C,不是吗?
如果你提到一个C初学者的5星级标题,我将不胜感激
开头。请注意,我不是一个初学者,我练习了
C 3年,停了6,现在我回来了agian。所以我真正需要的是快速刷新我的信息。
再次感谢。干杯!
Mazen
Hi Mike,
Thanks for your help. Ctrl+Z was the trick. I am reading the 2nd
edition of K&R and I thought the phrase "ANSI C Compliant" on the
cover meant that this is standard C, isn''t?
I would appreciate if you mention some 5 stars titles for a C beginner
to start with. Please note that I am not a total beginner, I practiced
C for 3 years, stopped for 6 and now I am back agian. So what I really
need is a fast refresh to my information.
Thanks again. Cheers!
Mazen
这篇关于Windows中的EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!