问题描述
所有的问候,
这是另一个令人难以置信的愚蠢问题。我觉得愚蠢,但是
我别无选择。我正在通过K& R2和第1.5.2节
(角色计数),我决定试用这个程序:
/ * count characters在输入;第一个版本* /
#include< stdio.h>
int main(无效)
{
long nc;
nc = 0;
while(getchar()!= EOF)
++ nc;
printf("%ld \ n",nc);
返回0;
} ,我跑了。我输入了一些字母和数字,他们在屏幕上重复了
(如预期的那样)。但那又怎样?如何获得输入字符的
数?我试过ctrl-d(我得到一个钻石),ctrl-z
(程序终止)和ctrl-c(程序终止)。我做错了什么
或我理解错误的是什么?非常感谢任何帮助。
最好,
newby2c
-
技术支持: 我可以帮你吗?
客户:我正在写我的第一封电子邮件。
技术支持:好的,似乎是什么成为问题?
客户:嗯,我可以得到''a''。但是我该怎么把它放在它周围?
Greetings all,
Here is another incredibly silly question. I feel foolish asking it, but
i''ve no other choice. I was going through K&R2 and at section 1.5.2
(Character Counting), I decided to try out the program:
/* count characters in input; 1st version */
#include <stdio.h>
int main(void)
{
long nc;
nc=0;
while(getchar()!=EOF)
++nc;
printf("%ld\n",nc);
return 0;
}
after compiling it, I ran it. I typed in some letters and numbers and they
were repeated on the screen (as expected). But then what? How do I get the
count of the characters typed? I tried ctrl-d (I get a diamond), ctrl-z
(program terminates), and ctrl-c (program terminates). What am I doing wrong
or what am I understanding wrong? Any help is much appreciated.
Best,
newby2c
--
Tech Support: "How may I help you?"
Customer: "I''m writing my first email."
Tech Support: "Ok, what seems to be the problem?"
Customer: "Well I can get the ''a''. But how do I put the circle around it?"
推荐答案
启动你的程序,键入你的行,
然后点击回车键,
然后你的EOF,这是我机器上的ctrl-z ,
然后再次点击回车键。
Start your program, type your line,
then hit the enter key,
then your EOF, which is ctrl-z on my machine,
then hit the enter key again.
这篇关于EOF问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!