C language provides a mechanism called inline function. The property of inline function is, compiler inserts the entire body of the function in the place where inline function call is used in the program.
// Inline function in C
inline void sum(int x, int y)
{
int z;
z=x +
y;
printf(“sum is %d”,z);
}
void main()
{
int x=5,y=6;
sum(x,y);
}
Following are situations where inline function may not work
1. if the function is recursive.
2. if the function contain static
variables.
3. if the functions contains control structure
statements.
4. and the function main cannot work as inline.
No comments:
Post a Comment