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?

Header Files in C
There are 2 types of header files

  1. Built-in the header file
  2. User-defined header file

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 -
 

  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. #include <ctype.h>
  7. #include <conio.h>
  8. #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).

Original Post - header files in c

Post a Comment

Previous Post Next Post