#include <stdio.h>
main()
{
int a,b,c;
int *p;
scanf("%d%d%d",&a,&b,&c);
p=fun_cmp(&a,&b,&c);
printf("%d %d\n",p,*p);
}
int *fun_cmp(int *x,int *y,int *z )
{
if(*x>=*y&&*x>=*z) return x;
if(*y>=*x&&*y>=*z) return y
else return z;
}
附加一道类似的,
#include <stdio.h>
main() /*返回值是指针*/
{
int *fun_cmp(int *x,int *y);
int a,b;
int *p;
scanf(" %d %d ",&a,&b);
p=fun_cmp(&a,&b);
printf("%d\n",p); /**/
printf("%d\n ",*p); /**/
}
int *fun_cmp(int *x,int *y)
{
if(*x>*y)
return x;
else
return y;
}
如果把scanf换成 int a=1,b=2; 的话此程序就正常;
请求以上两题(特别是第一题)的解答
第一道题的错误信息如下:
warning C4013: 'fun_cmp' undefined; assuming extern returning int
warning C4047: '=' : 'int *' differs in levels of indirection from 'int '
error C2040: 'fun_cmp' : 'int *(int *,int *,int *)' differs in levels of indirection from 'int ()'
error C2143: syntax error : missing ';' before 'else'
摇曳的蔷薇
梵蒂冈之花
相关分类