I have seen both the below links to understand difference between inline function and normal function
https://www.geeksforgeeks.org/inline-function-in-c/
https://www.tutorialspoint.com/what-is-an-inline-function-in-c-language
I have created one normal function "add" and one inline function "sum" I don't see any difference when program execute
Output
can anyone show me how inline function is different as compare to normal function ?
https://www.geeksforgeeks.org/inline-function-in-c/
https://www.tutorialspoint.com/what-is-an-inline-function-in-c-language
I have created one normal function "add" and one inline function "sum" I don't see any difference when program execute
C:
#include<stdio.h>
int add( int x, int y)
{
int result = x + y;
return result;
}
// I am using GCC compiler
static inline int sum( int x, int y)
{
int result = x + y;
return result;
}
int main()
{
int a = add ( 2, 5);
printf(" a : %d \n", a);
int b = sum( 2, 5);
printf(" b : %d \n", b);
return 0;
}
Code:
a : 7
b : 7