在我的代码中使用
gets()
时,编译器会报错。warning: the 'gets' function is dangerous and should not be used.`
并且
warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638)
[-Wdeprecated-declarations]
有具体的原因吗?
fgets
与stdin
。正如消息所说,gets
是危险的,因为它无法防止缓冲区溢出。 - Weather Vane