Answers for "inline function in c example"

C
0

inline function in c example

// file test.h
#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED
inline int sum (int a, int b)
{
    return a+b;
}
#endif
 
// file sum.c
#include "test.h"
extern inline int sum (int a, int b); // provides external definition
 
// file test1.c
#include <stdio.h>
#include "test.h"
extern int f(void);
 
int main(void)
{
    printf("%d\n", sum(1, 2) + f());
}
 
// file test2.c
#include "test.h"
 
int f(void)
{
    return sum(2, 3);
}
Posted by: Guest on May-05-2022

Code answers related to "C"

Browse Popular Code Answers by Language