C Inline Functions

Inline functions are those functions whose function declaration contains the inline keyword. The Inline keyword suggests the compiler to replace the function call with the body of the inline function. Compiler may or may not perform function substitution.


inline function-name (parameters)
    //A short or single line body

Example Code


//static is required to force the compiler to consider this function in the linker.
static inline int max(int x, int y) 
    return (x > y) ? x : y; 
int main(void) 
    int getmax; 
    // inline function call 
    getmax = max(10,20); 
    printf("Max of 10 and 20 is: %d\n", getmax); 
    return 0;


Max of 10 and 20 is: 20


C Programming

Remember to follow community guidelines and don't go off topic.