这个程序用VISUAL STUDIO为什么会报错?用VC就不报错?求高...
时间:10-02
整理:3721RD
点击:
#include <stdio.h>
int main()
{
int max(int, int);
int min(int, int);
int(*p1)(int, int);
int a, b, c, n;
printf("please enter two numbers:");
scanf_s("%d,%d", &a, &b);
printf("choose 1 or 2 :");
scanf_s("%d", &n);
if (n == 1)p1 = max;
else if (n == 2)p1 = min;
c = (*p1)(a, b);
printf("a=%d\nb=%d\n", a, b);
if (n == 1)printf("max=%d\n", c);
else if (n == 2)printf("min=%d\n", c);
return 0;
}
int max(int x, int y)
{
int z;
z = (x > y) ? x : y;
return z;
}
int min(int x, int y)
{
int z;
z = (x < y) ? x : y;
return z;
}
报错内容是:可能使用了未被初始化的本地址指针变量p1
int main()
{
int max(int, int);
int min(int, int);
int(*p1)(int, int);
int a, b, c, n;
printf("please enter two numbers:");
scanf_s("%d,%d", &a, &b);
printf("choose 1 or 2 :");
scanf_s("%d", &n);
if (n == 1)p1 = max;
else if (n == 2)p1 = min;
c = (*p1)(a, b);
printf("a=%d\nb=%d\n", a, b);
if (n == 1)printf("max=%d\n", c);
else if (n == 2)printf("min=%d\n", c);
return 0;
}
int max(int x, int y)
{
int z;
z = (x > y) ? x : y;
return z;
}
int min(int x, int y)
{
int z;
z = (x < y) ? x : y;
return z;
}
报错内容是:可能使用了未被初始化的本地址指针变量p1
在线等高手啊。