gpt4 book ai didi

c - 我无法理解的几个错误

转载 作者:太空宇宙 更新时间:2023-11-04 07:05:19 24 4
gpt4 key购买 nike

所以我写了这个:

#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS

int main() {
float balance;
char type;

printf("Card balance: ");
scanf("%f", &balance);

do {
printf("Vehicle type: ");
scanf("%c", &type);
if (type != 'B' || type != 'b' || type != 'C' || type != 'c' || type != 'T' || type != 't') {
printf("Incorrect vehicle type!");
}
} while(type != 'B' || type != 'b' || type != 'C' || type != 'c' || type != 'T' || type != 't') ;

system("pause");
return 0;
}

当我尝试运行它时,出现了这些错误:

1.scanf: This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

2.system undefined; assuming extern returning int

最佳答案

scanf 将变量的地址作为参数。所以,你需要做

scanf("%f", &balance);
scanf("%c", &type);

对于system,你需要包含stdlib.h

关于c - 我无法理解的几个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33596851/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com