In this tutorial, we will learn what are header files in c programming and the types of header files, and how to use header files. So let us go into the deep models.
What are header files in c?
Header files are those files in which c functions declaration and macro definitions are shared between various source files. By using the header files we can save time as the program becomes short and readable. There are two types of header files built-in header files and user-defined header files.
The header files serve two purposes: first, the system header files declare the interface to the parts of the operating system. They help in supplying the definition and declaration needed for invoking the system calls and libraries. Secondly, the header files contain the declaration for interfaces between the source files of the program.
All the header files have a β.hβ extension. This extension contains a c function declaration and the macro definitions. The header files can be requested using the preprocessor directive which is #include.
What are the types of header files?
There are 2 types of header files
Built-in header file
This is the header file that is provided by the compiler. We can not change anything in the built-in header files. Header files provide the basic functionality.
For example -
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <conio.h>
#include <float.h>
User-defined header file
The User-defined header files are defined by the user. These are created using the file program. The user-defined header files are like the built-in header file.
For example: #include βFile_name.hβ
How to use header files?
To use these Header files in a program we have to use the #include directive. Whenever we want to include built-in header files we write < > (angle brackets).
-Learn into deep - Header Files in C
Oldest comments (0)