C Header Files
C Language has different libraries and predefined functions which is pre-written with it. C header files make the Programmer write the programs easily. Learn about the C header files and how these header files can be included in the C program.
What are the Header Files?
The Header files hold the definitions of various functions and their associated variables which need to be imported into your C program with the help of the pre-processor #include statement. All the header files have the “.h” extension which contains C function declaration and macro definitions. The header files can be included using the preprocessor directive “#include”.
The default header file we use in all C programs is ‘stdio.h’. In other words, including the header file means using the content of header files in the source program. The following is the syntax of the header file:
Syntax:
#include
(or)
#include “file”
The first syntax includes system-oriented header files in our C program whereas the second syntax includes user-defined header files for your program.
How header files work?
The C’s #include preprocessor directive statement goes through the C preprocessors for scanning if any such file available before abiding by the rest of your existing source file. The following example explains how header files work:
Example:
The header file example.h which has the following statement:
char *example (void);
The main C program includes an example.h file in the program
#include
int a;
#include “example.h”
int main()
{
printf(“Example Program”);
return 0;
}
Hence, the compiler will interpret the entire program as below:
#include
int a;
char *example (void);
int main()
{
printf(“Example Program”);
return 0;
}