Home>Article>Backend Development> In C language, what is an inline function?

In C language, what is an inline function?

Christopher Nolan
Christopher Nolan forward
2023-09-08 11:21:09 1101browse

In C language, what is an inline function?

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 }

Example

The following are inline functions for a C program:

Live Demo-->
#include inline int mul(int a, int b) //inline function declaration{ return(a*b); } int main(){ int c; c=mul(2,3); printf("Multiplication:%d

",c); return 0; }

Output

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:encrypted string Next article:encrypted string