EOF(新手) [英] EOF (novice)

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

问题描述




-

Alan C这篇文章的结尾是w

q


来自K& R:


#include< stdio.h>


main()


/ *复制输入到输出* /


{


int c;


c = getchar();

while(c!= EOF){


putchar(c);

c = getchar ();


}


}

如果我正确阅读文本,这个程序应该

在我输入-1时终止(EOF在我的系统中定义,

Linux)。


但它没有。只是保持正确的货运。


给出了什么?


AC

解决方案

输入-1时,输入两个字符'' - ''和''1'。两者都不等于-1。

也许你应该输入Ctrl-D(?),这将产生一个EOF。


" Alan Connor" < ZZ **** @ xxx.yyy> D'è?óê?t

新闻:Fi **************** @ newsread2.news.pas.earthli nk.net ...



- Alan C这篇文章以w
来结束。

来自K& R:

#include< stdio.h>

main()

/ *复制输入到输出* /

{

int c;

c = getchar();
while(c!= EOF){

putchar(c);
c = getchar();

}


如果我正确阅读文本,该程序应该在我输入-1(我的系统上定义的EOF,Linux)。

但它不是。只是保持正确的货运。

是什么给予​​的?

blockquote>


Alan Connor< zz **** @ xxx.yyy>写道:


绝对没有。


此外,


"并且sig仅限于在分隔符正下方的四条线。


Killfiled 30天。


清理你的行为。

Alan Connor,comp.lang.c,2003年11月14日。


Alex


周三,2003年11月19日01:30:57 -0000,Seesaw< ma ******* @ hotmail.com>写道:



当你输入-1时,你输入两个字符'' - ''和''1''。两者都不等于-1。
也许你应该输入Ctrl-D(?),这将产生一个EOF。




Ctrl-c工作得很好。但是对K& R或常见问题解答中的这个

一无所知。


找不到任何单一的线索。


然而,这里有很多人一直说K& R是为初学者提供的。$

AC




--
Alan C this post ends with w
q

From K&R:

#include <stdio.h>

main()

/* copy input to output */

{

int c;

c = getchar();
while (c != EOF) {

putchar(c);
c = getchar();

}

}
If I am reading the text correctly, this program should
terminate when I enter -1 (EOF as defined on my system,
Linux).

But it doesn''t. Just keeps right on trucking.

What gives?

AC

解决方案

When you enter -1, you enter two characters ''-'' and ''1''. Neither equals -1.
Maybe you should enter Ctrl-D(?), which will produce a EOF.

"Alan Connor" <zz****@xxx.yyy> D′è?óê?t
news:Fi****************@newsread2.news.pas.earthli nk.net...



--
Alan C this post ends with w
q

From K&R:

#include <stdio.h>

main()

/* copy input to output */

{

int c;

c = getchar();
while (c != EOF) {

putchar(c);
c = getchar();

}

}
If I am reading the text correctly, this program should
terminate when I enter -1 (EOF as defined on my system,
Linux).

But it doesn''t. Just keeps right on trucking.

What gives?

AC



Alan Connor <zz****@xxx.yyy> wrote:

Absolutely nothing.

Also,

"And sigs are limited to the four lines immediately below the delimiter.

Killfiled for 30 days.

Clean up your act."
Alan Connor, comp.lang.c, Nov 14, 2003.

Alex


On Wed, 19 Nov 2003 01:30:57 -0000, Seesaw <ma*******@hotmail.com> wrote:



When you enter -1, you enter two characters ''-'' and ''1''. Neither equals -1.
Maybe you should enter Ctrl-D(?), which will produce a EOF.



Ctrl-c works just fine. But absolutely nothing was said about this
in K&R or the FAQ.

There isn''t a single clue to be found.

Yet a large number of people here keep saying that K&R is for
beginners.
AC


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

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