首页
社区
课程
招聘
[求助]一段用了gets()的C++代码我想用GCC编译通过,应该加什么参数?
发表于: 2018-3-11 17:10 3029

[求助]一段用了gets()的C++代码我想用GCC编译通过,应该加什么参数?

2018-3-11 17:10
3029
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

bool IsPasswordOK(void) {
	char Password[12];

	gets(Password);
	return 0 == strcmp(Password, "goodpass");
}

int main(void) {
	bool PwStatus;

	puts("Enter password:");
	PwStatus = IsPasswordOK();
	if (PwStatus == false) {
		puts("Access Denied");
		exit(-1);
	}
	else {
		puts("Access Granted");
	}
	return 0;
}
现在报错如下:
error: 'gets' was not declared in this scope。


[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 23352
活跃值: (3496)
能力值: ( LV13,RANK:648 )
在线值:
发帖
回帖
粉丝
2
gets()被弃用了,用fgets()吧
2018-3-11 17:19
0
雪    币: 106
活跃值: (764)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
3
可是你这段代码。。。
bool应该会先报错吧。。。

要  #include  <stdbool.h>  一下。
2018-3-11 23:01
0
游客
登录 | 注册 方可回帖
返回