Chinaunix

标题: 关于gets()函数 [打印本页]

作者: aero    时间: 2004-03-04 13:31
标题: 关于gets()函数
我再linux用gcc编译c程序的时候,用gets函数的话,就老是给我下面的警告信息:
/tmp/ccyhTLKy.o(.text+0x53): In function `main':
: the `gets' function is dangerous and should not be used.
这是怎么会事啊?

不用gets,用scanf的话,读字符串,到空格就结束了.怎么改呢?
作者: win_hate    时间: 2004-03-04 13:34
标题: 关于gets()函数
原帖由 "aero" 发表:
我再linux用gcc编译c程序的时候,用gets函数的话,就老是给我下面的警告信息:
/tmp/ccyhTLKy.o(.text+0x53): In function `main':
: the `gets' function is dangerous and should not be used.
这是怎么会事啊?

..........


gets 容易受缓冲区溢出的攻击. 那个警告说的就是它.
用 fgets
作者: aero    时间: 2004-03-04 15:58
标题: 关于gets()函数
哦,谢谢班长.




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2