[Warning] assignment from incompatible pointer type [enabled by default]
刚学指针,不知道我的程序为什么会出现这个警告QAQ
感谢解答~
#include <stdio.h>
char max(char a, char b)
{ return (a>b)?a:b;
}
int main()
{ char a, b;
char (*pm)();
pm=max;
scanf("%c %c", &a, &b);
printf("%c\n", (*pm)(a,b));
return 0;
}
[Warning] assignment from incompatible pointer type [enabled by default]
又写了一个相似的代码,这个就没有报错
#include <stdio.h>
int max(int a, int b)
{ return a>b?a:b;
}
int main()
{
int a, b, (*pm)();
scanf("%d %d", &a, &b);
pm=max;
printf("%d\n",(*pm)(a,b));
return 0;
}
char (*pm)(char,char);定义的时候这样试下呢