I’m just learning C typing and am wondering what’s wrong with the following example. When I try to compile it I get the error: “format ‘%i’ expects type int, but argument 2 has type ‘int(*)(int, int)’.
#include <stdio.h>
int difference (int x, int y);
int sum(int x, int y);
main(){
int differ = difference(10, 5);
int thesum = sum(3, 4);
printf("differnece: %i, sum: %i \n", differ, sum);
}
int sum(int x, int y){
return x + y;
}
int difference (int x, int y){
return x - y;
}
You used
sum(a function) where you presumably intendedthesum(an(int)variable).