小编Chh*_*rum的帖子

错误C4996:'scanf':此函数或变量在c编程中可能不安全

我创建了一个小应用程序,通过使用带参数的用户定义函数来查找最大数量.当我运行它时,它会显示此消息

错误1错误C4996:'scanf':此函数或变量可能不安全.请考虑使用scanf_s.要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS.详细信息请参见在线帮助.

我该怎么做才能解决这个问题?

这是我的代码

#include<stdio.h>

void findtwonumber(void);
void findthreenumber(void);

int main() {
    int n;
    printf("Fine Maximum of two number\n");
    printf("Fine Maximum of three number\n");

    printf("Choose one:");
    scanf("%d", &n);
    if (n == 1)
    {
        findtwonumber();
    }
    else if (n == 2)
    {
        findthreenumber();
    }
    return 0;
}

void findtwonumber(void)
{
    int a, b, max;
    printf("Enter a:");
    scanf("%d", &a);
    printf("Enter b:");
    scanf("%d", &b);
    if (a>b)
        max = a;
    else
        max = b;
    printf("The max is=%d", max);
}

void findthreenumber(void)
{
    int a, …
Run Code Online (Sandbox Code Playgroud)

c windows tr24731 visual-studio c11

13
推荐指数
3
解决办法
8万
查看次数

标签 统计

c ×1

c11 ×1

tr24731 ×1

visual-studio ×1

windows ×1