The inline function can be substituted at the place where the function call is happening. Function substitution is always compiler choice.
In an inline function, a function call is replaced by the actual program code.
Most of the Inline functions are used for small computations. They are not suitable for large computing.
An inline function is similar to a normal function. The only difference is that we place a keyword inline before the function name.
Inline functions are created with the following syntax −
inline function_name (){ //function definition }
Example
Following is the C program for inline functions −
#include<stdio.h> inline int mul(int a, int b) //inline function declaration{ return(a*b); } int main(){ int c; c=mul(2,3); printf("Multiplication:%d\n",c); return 0; }
Output
When the above program is executed, it produces the following result −
6