What is header file ?
In C programming language there are many standard pre-defined functions, that we can directly include in our code to make programming easy. There are many standard header file that is ready to use, or we can make our own header file(user defined header file).
We have to include the header file using the preprocessing directive “#include”. Every header file has a “.h” extension.
SYNTAX –
1. #include<file_name.h> – standard header file [all header file should have .h extension]
2. #include”file_name.h” – user defined header file
Header files contains –
1. Functions
2. Macros
3. Data type definitions
Example :
Creating our own header file:
//We have declared a function to multiply 3 integers.
int M(int a, int b, int c)
{
return (a*b*c);
}
Including user defined header file in our code:
#include
#include”Multiply.h”
int main()
{
//We are calling the function M() from our user defined heaer file Multiply.h
printf(“%d”,M(2,2,3));
return 0;
}
12