Hi everyone,
I couldn't decide where I should use the inline keyword: in function prototype of the function definiton.
Code:
#include <stdio.h>
int func(int x, int y);
int main(void){
int a,b;
printf("Enter values for x and y\n");
scanf("%d",&a);
scanf("%d",&b);
int c=func(a,b);
printf("%d",c);
return 0;
}
inline int func(int x, int y){
return (x+y)*(x+y);
}
Code:
#include <stdio.h>
inline int func(int x, int y);
int main(void){
int a,b;
printf("Enter values for x and y\n");
scanf("%d",&a);
scanf("%d",&b);
int c=func(a,b);
printf("%d",c);
return 0;
}
int func(int x, int y){
return (x+y)*(x+y);
}
These both works but when I use inline in both of them it doesn't work.
Code:
#include <stdio.h>
inline int func(int x, int y);
int main(void){
int a,b;
printf("Enter values for x and y\n");
scanf("%d",&a);
scanf("%d",&b);
int c=func(a,b);
printf("%d",c);
return 0;
}
inline int func(int x, int y){
return (x+y)*(x+y);
}
As my understanding I should use it either in prototype or definetion but not both. However is there any difference between using it in prototype or definition?