关于gets()函数 error: 'gets' was not declared in this scope; did you mean 'fgets'

关于gets函数

有一段时间没有写算法了,今天重新写一道已经AC的题发现不通过。
发现如下报错:error: 'gets' was not declared in this scope; did you mean 'fgets'?

也就是说不支持使用gets函数了
请教了别人,应该是因为这个函数不安全。


解决方法1

fgets(array,len,stdin);
//分别是你的字符数组,想要读取的长度,读取的来源

解决方法2

cin.getline(arr,len)
//参数依次为:数组,想要读取的长度
posted @ 2022-10-26 00:09  wenli7363  阅读(801)  评论(0编辑  收藏  举报