首页 > 其他分享 >关于gets()函数 error: 'gets' was not declared in this scope; did you mean 'fgets'

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

时间:2022-10-26 00:23:12浏览次数:59  
标签:declared did fgets scope gets was

关于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)
//参数依次为:数组,想要读取的长度

标签:declared,did,fgets,scope,gets,was
From: https://www.cnblogs.com/jye159X/p/16826915.html

相关文章