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

In C language, what is an inline function?

WBOY
WBOYforward
2023-09-08 11:21:091106browse

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<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;
}

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 stringNext article:encrypted string