How to use inline function in C

1 Answer

0 votes
/*

inline function = the compiler copies the code from the function definition 
directly into the code of the calling function, rather than creating a separate 
set of instructions in memory. 

*/

#include <stdio.h>

static inline int add(int x, int y) { // == static int add(int x, int y)
	return x + y;
}

int main() {
    int result = add(23, 6);
  
    printf("%d", result);
  
    return 0; 
}
    
    
    
/*
run:
    
29
   
*/

 



answered Apr 4, 2024 by avibootz
edited Dec 5, 2024 by avibootz
...