原文连接:http://www.juzicode.com/cpp-error-devc-conflicting-types-for-add/
错误提示:
定义函数时提示:[Error] conflicting types for ‘add’:
//juzicode.com;vx:桔子code
#include "stdio.h"
int main(void)
{
printf("juzicode.com;vx:桔子code\n");
float c = add(11.1, 55.5);
printf("c = %f \n", c);
return 0;
}
float add(float a, float b)
{
return a + b;
}

错误原因:
1、float add(float a, float b)函数在调用之后定义,导致和main()调用时推定的函数原型冲突。
解决方法:
1、在mani()之前声明函数原型:
//juzicode.com;vx:桔子code
#include "stdio.h"
float add(float a, float b);//调用前声明函数原型
int main(void)
{
printf("juzicode.com;vx:桔子code\n");
float c = add(11.1, 55.5);
printf("c = %f \n", c);
return 0;
}
float add(float a, float b)
{
return a + b;
}

如果本文还没有完全解决你的疑惑,你也可以在微信公众号“桔子code”后台给我留言,欢迎一起探讨交流。
