We know that built-in header files contain the prototypes
for many useful functions. We can also create our own header file with custom
function.
For example – Let us create one header file called mul.h
which contains the function sum. This function will return the sum of 2
arguments that we pass.
Source code of Sum.h header file is given below.
int mul(int a, int b)
{
return (a*b);
}
Source code of abc.c is given below. Please note how we have
included above header file in abc.c and we have called mul function which is
defined in mul.h
#include <stdio.h>
#include "mul.h"
int main()
{
printf("%d", mul(3,4));
}
No comments:
Post a Comment
Leave your valuable feedback. Your thoughts do matter to us.