使用得到安全 [英] Use gets Safely

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

问题描述

我写了这个程序,保证安全使用。


#include< stdio.h>

int main(void)

{

char name [588 + 1];

printf("输入你的姓氏:");

fflush(stdout);

printf(" Hi%s \ n",gets(name));

返回0;

}


你看,世界上最长的姓氏是588个字符,这里解释为



http://www.everything2.com/index.pl?node_id=1534419


所以,我的程序适用于世界上的每个人。保证。


-

比利

I wrote this program which guarantees to use gets safely.

#include <stdio.h>
int main(void)
{
char name[588+1];
printf("Enter your last name: ");
fflush(stdout);
printf("Hi %s\n",gets(name));
return 0;
}

You see, the longest last name in the world is 588 characters, as
explained here:

http://www.everything2.com/index.pl?node_id=1534419

So, my program works for everyone in the world. Guaranteed.

--
Billy

推荐答案

1月14日, 9:27 * pm,Billy Bong< billyb655 ... @ aol.comwrote:
On Jan 14, 9:27*pm, Billy Bong <billyb655...@aol.comwrote:

我写了这个程序,保证安全使用。


#include< stdio.h>

int main(无效)

{

* * char name [588 + 1];

* * printf("输入你的姓氏:");

* * fflush(stdout);

* * printf(" Hi%s \ n",gets(name));

* * return 0;


}


你看,世界上最长的姓氏是588个字符,这里解释为



http://www.everything2.com/index.pl?node_id=1534419


所以,我的程序适用于世界上的每个人。保证。
I wrote this program which guarantees to use gets safely.

#include <stdio.h>
int main(void)
{
* *char name[588+1];
* *printf("Enter your last name: ");
* *fflush(stdout);
* *printf("Hi %s\n",gets(name));
* *return 0;

}

You see, the longest last name in the world is 588 characters, as
explained here:

http://www.everything2.com/index.pl?node_id=1534419

So, my program works for everyone in the world. Guaranteed.



如果他们输入额外的十个字母,只是为了好玩怎么办?


如果他们喂它100 MB怎么办?二进制文件?

What if they type in an extra ten letters, just for fun?

What if they feed it a 100 MB binary file?


文章< 9c *************************** ******* @ v29g2000hsf。 googlegroups.com>,

user923005< dc ***** @ connx.comwrote:
In article <9c**********************************@v29g2000hsf. googlegroups.com>,
user923005 <dc*****@connx.comwrote:

> 1月14日,9日:27 = A0pm,Billy Bong< billyb655 ... @ aol.comwrote:
>On Jan 14, 9:27=A0pm, Billy Bong <billyb655...@aol.comwrote:

>我写了这个程序,保证使用安全。
>I wrote this program which guarantees to use gets safely.


> = A0 = A0char name [588 + 1];
>=A0 =A0char name[588+1];


> = A0 = A0printf(" Hi%s \ n,获取(名称));
>=A0 =A0printf("Hi %s\n",gets(name));


>你知道,世界上最长的姓氏是588个字符,因为<这里解释:
>You see, the longest last name in the world is 588 characters, as
explained here:


> http://www.everything2.com/index.pl?node_id=1534419


>所以,我的程序适用于世界上的每个人。保证。
>So, my program works for everyone in the world. Guaranteed.


>如果他们输入额外的十个字母,只是为了好玩怎么办?
>What if they type in an extra ten letters, just for fun?



或者如果他们有自己名字的拼写错误(在588

字符中不太可能)。

-

有什么事可以说,看,这是新的吗?它已经过去了,这已经是我们面前的旧时代了。 - 传道书

Or if they have a typo in their own name (not unlikely in 588
characters).
--
"Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us." -- Ecclesiastes


Billy Bong写道:
Billy Bong wrote:

我写了这个程序,保证安全使用。


#include< stdio.h>

int main(无效)

{

char姓名[588 + 1];

printf("输入你的姓氏:");

fflush(标准输出);

printf (Hi%s\ n,获取(姓名));

返回0;

}


你看,世界上最长的姓氏是588个字符,这里解释为



http://www.everything2.com/index.pl?node_id=1534419


所以,我的程序适用于世界上的每个人。保证。
I wrote this program which guarantees to use gets safely.

#include <stdio.h>
int main(void)
{
char name[588+1];
printf("Enter your last name: ");
fflush(stdout);
printf("Hi %s\n",gets(name));
return 0;
}

You see, the longest last name in the world is 588 characters, as
explained here:

http://www.everything2.com/index.pl?node_id=1534419

So, my program works for everyone in the world. Guaranteed.



究竟如何确保用户被限制输入

a真正的姓氏,以及它如何确保约束

最长的姓氏/仍然保持/何时运行?


很好的尝试。


-

远足的刺猬

花了很长时间,比最慷慨的估计要长得多。

- James White,/部门总干事/

Exactly how does it ensure that the user is constrained to enter
a genuine last name, and how does it ensure that the constraints
for a longest last name /still hold/ when it runs?

Nice try.

--
Far-Fetched Hedgehog
"It took a very long time, much longer than the most generous estimates."
- James White, /Sector General/


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

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