为什么我自己写的max函数只能输出输入的第一个数而不是最大的

 #include<stdio.h>

int max(int a, int b);

int main()
{
    int a, b;
    scanf_s("%d,%d", &a, &b);
    printf("the maximum is: %d", max(a, b));
    return 0;
}

int max(int a, int b)
{
    return ((a > b) ? a : b);
}

按格式输入,你scanf中的%d,%d中有个逗号,你输入的时候也必须以逗号分隔,否则b没有接受到数据,初值为一个很大的负值,所以每次都输出了第一个
图片说明

你去了解一下scanf()和scanf_s()的区别应该就知道为什么了。