怎么了 ? [英] What's wrong ?

查看:65
本文介绍了怎么了 ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。

我刚刚从我的书中复制了这段代码而没有修改:


#include< stdio.h>
$输入中b $ b / * count个字符;第一个版本* /

main()

{

long nc;


nc = 0 ;

while(getchar()!= EOF)

++ nc;

printf("%ld \ n",nc );

}


没有输出,也没有完成。我尝试添加printf在

代码的结尾,但它没有显示。


我正在使用带有Windows XP Home的MinGW开发人员工作室。 />

提前致谢。

Daniel

解决方案

Daniel.C写道:


你好。

我刚刚从我的书中复制了这段代码而没有修改:


#在输入中包含< stdio.h>

/ * count个字符;第一个版本* /

main()

{

long nc;


nc = 0 ;

while(getchar()!= EOF)

++ nc;

printf("%ld \ n",nc );

}


没有输出,也没有完成。我尝试添加printf在

代码的结尾,但它没有显示。


我正在使用带有Windows XP Home的MinGW开发人员工作室。 />

提前致谢。

Daniel



你必须输入一个结尾文件字符

因为那是你指定的条件。


在windows下你可以在linux下键入ctrl + Z

你会键入ctrl + d

-

jacob navia

jacob at jacob point remcomp point fr

logiciels / informatique
http://www.cs.virginia.edu/~ lcc-win32


文章< 47 ********************** @ news.free.fr>,

Daniel.C< dc ************* @ free.frwrote:


>我刚从我的书中复制了这段代码而没有修改:

#include< stdio.h>
/ *计算我的字符NPUT;第一版* /
主()
{
长nc;

nc = 0;
而(getchar()!= EOF)

++ nc;
printf("%ld \ n",nc);
}


>没有输出,也没有完成。



您是否在标准输入上给它一些输入?通过键入一些

字符后跟一个文件结束指示(可能是控制-Z

或control-D),或者从文件重定向?


- Richard

-

:wq


Daniel.C写道:


你好。

我刚从我的书中复制了这段代码而没有修改:


#include< stdio.h>

/ *计数字符输入;第一个版本* /

main()

{

long nc;


nc = 0 ;

while(getchar()!= EOF)

++ nc;

printf("%ld \ n",nc );

}


没有输出,也没有完成。我尝试添加printf在

代码的结尾,但它没有显示。



在getchar()返回EOF之前,这个程序只是静默计算
而不产生输出。

检测到输入结束后出现输出。


我正在使用带有Windows XP Home的MinGW开发人员工作室。



如果输入来自你的键盘,只需拿走

你的手就决定不再按任何键了

告诉程序你已完成打字。为了它所有它

知道,你正在考虑很难或暂时离开

浴室休息或什么的,它会一直等待

下一把钥匙。在Windows上,惯例是按ctrl-Z

来表示Th-th-that's all,伙计们!其他系统还有其他约定。


如果输入来自其他地方,那么其他来源将是b / b
特定方式表明它已经完成了所有

。磁盘驻留文件通常不需要帮助,但

套接字之类的东西可能。


-

Eric Sosman es*****@ieee-dot-org.inva lid


Hello.
I just copied this code from my book with no modification :

#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;

nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}

There is no output, and no completion either. I tried adding a "printf" at
the end of the code, but it doesn''t display.

i''m using MinGW developer studio with windows XP home.

Thanks in advance.
Daniel

解决方案

Daniel.C wrote:

Hello.
I just copied this code from my book with no modification :

#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;

nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}

There is no output, and no completion either. I tried adding a "printf" at
the end of the code, but it doesn''t display.

i''m using MinGW developer studio with windows XP home.

Thanks in advance.
Daniel

You have to input an end of file character
since that is the condition you specified.

Under windows you would type ctrl+Z under linux
you would type ctrl+d
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32


In article <47**********************@news.free.fr>,
Daniel.C <dc*************@free.frwrote:

>I just copied this code from my book with no modification :

#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;

nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}

>There is no output, and no completion either.

Are you giving it some input on standard input? Either by typing some
characters followed by an end-of-file indication (probably control-Z
or control-D), or redirecting from a file?

-- Richard
--
:wq


Daniel.C wrote:

Hello.
I just copied this code from my book with no modification :

#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;

nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
}

There is no output, and no completion either. I tried adding a "printf" at
the end of the code, but it doesn''t display.

Until getchar() returns EOF, this program just counts
silently and produces no output. The output appears after
end-of-input is detected.

i''m using MinGW developer studio with windows XP home.

If the input is coming from your keyboard, simply taking
your hands away and deciding not to press any more keys won''t
tell the program that you''re finished typing. For all it
knows, you''re thinking Very Hard or temporarily away on a
bathroom break or something, and it will keep waiting for
that next key. On Windows, the convention is to press ctrl-Z
to indicate "Th-th-that''s all, folks!" Other systems have
other conventions.

If the input is coming from somewhere else, there will
be other, source-specific ways to indicate that it''s all
finished. Disk-resident files typically need no help, but
things like sockets might.

--
Eric Sosman
es*****@ieee-dot-org.invalid


这篇关于怎么了 ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆