Inline functions can be replaced where the function call occurs. Function substitution is always the compiler's choice.
In an inline function, the function call is replaced by the actual program code.
Most inline functions are used for small calculations. They are not suitable for large calculations.
Inline functions are similar to ordinary functions. The only difference is that we put a keyword inline before the function name.
Inline functions are created using the following syntax -
inline function_name (){ //function definition }
The following are inline functions for a C program:
Live Demo-->#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</p><p>",c); return 0; }
When the above program is executed, the following results will be produced-
6
The above is the detailed content of In C language, what is an inline function?. For more information, please follow other related articles on the PHP Chinese website!