C Programming

Use Of Header File In C ( Easy Explanation With Pictures & List)

When it comes to c programming, the first thing which we have to do is to declare the header file. So the question is why we need to declare it?. Header file is the backbone of any programming language. In this post, I will try to clear all your doubt regarding header file.

What is Header File & why we use it in C

As the name suggests, the Header file is a special type of file which contains a lot of information like special type of functions, keywords, constants, etc which we generally need to create any program.

Generally, any programming language contains a lot of predefined functions, variables, keywords, classes, etc which we need to create a program and these predefined elements are defined in a special library called as header files. Not only functions and classes but also if we need to combine multiple files in any program we surely required these header files.

So the biggest question here is, why we declare header file rather than creating the function or any elements which we need and the answer is, time Yes header file saves our much time. Rather than creating multiple functions for accepting inputs or displaying outputs we simply need to declare the header file which contains to these function.

Header File in C

So the main purpose of using header files is

  • It saves our time.
  • It helps us to reuse the predefined elements such as functions, constants, classes, etc.

Declarations of Header File

  • Declaration of these header files are pretty simple. We just need to use the predefined statement to declare an header file in our program.
  • The basic format of the declaration of the header file is #include<header_file_name>
  • Here “#” is known as preprocessor directives. This will tell the compiler that this stdio.h or any other header file in not a C statement, it’s just a declaration of the header file.

For easy clarification please refer – 😍 Easy Explaination of addition of two numbers in C

C header file

Some popular header files ( List )

  • <stdio.h> – One of the main header file of c, use to implement various macros & functions like printf() & scanf().
  • <time.h> – It allows to insert or modify date or time in program.
  • <float.h> – It contains various constants related to float variable.
  • <string,h> – It contains different variables & mactros.
  • <fstream.h> – Use to take input & output in a program.
  • <stdlib.h> – It contains different functions as like malloc().
  • <iostream.h> – Use to take Input/Output.
  • <conio.h> – It contains functions for different console input/output.
  • <ctype.h> – It is use to handle characters in a program.
  • <limits.h> – It is use to define limits on integral types.


Leave a Reply

Your email address will not be published.