#include<stdio.h>
int main(void)
{
char word;
printf("请输入整数:");
scanf("%d", &word);
printf("整数转化的字符为:%c", word);
return 0;
}
出现以下错误:
错误'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.C:\Users\shi21\source\repos\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.cpp6
解决方法:
#define _CRT_SECURE_NO_WARNINGS;
把每一个scanf()改为scanf_s;
文章讨论了一个在C语言编程中常见的问题,即使用scanf函数时触发的安全警告。该警告建议使用更安全的scanf_s替代。解决方法是在代码中包含预处理器指令#define_CRT_SECURE_NO_WARNINGS,或者直接将所有scanf替换为scanf_s。
1万+





