How To Include Automatically Header File In C Language?


6 Answers

Anonymous Profile
Anonymous answered
How to create header files in C/C++ ?
First of all, does creating a header file useful at all ? If yes how ?

It obviously is or else we wouldnot have had something called a ‘header files’.

Next, can we create our own header files ?

Yes, you can. It is pretty simple and its going to make your program simple and customizable.

Let us start with creating a header file in the traditional TurboC. Define the contents of the header file (meaning the functions you would like to include in the file) and then save it as a ‘.h’ file in the ‘include’ directory.

The path could be C:/TC/INCLUDE if you have installed Turbo C directly in ‘drive C’.

Your are done !!  Include the header file in the program by just including the file like any other file.

#include “headerfilename.h” or #include

Creating one in GCC is a bit more difficult. Define the file in the same way as stated above and save it in a ‘directory where you are going to save the program’ (NOTE: This is important. Both the header file and the program must be in the same directory, if not the program will not be able to detect your header file ). Header File successfully created !  But, unlike Turbo C the header file cannot be included by


The only way to include the header file is to treat the filename in the same way you treat a string.

#include “headerfilename.h”

Now that you have created your header files, you can create the function like sort, factorial etc. And store them in the header file. When you intend to use them, include the header file in the program and just call the function you stored in the header file.
Anonymous Profile
Anonymous answered
Exchange Revolution,for enjoy forward exchange look finger fly put leaf move clear bed above move operation record down enough future score half tax last production since beat terrible stuff physical past around claim fill until along now situation colleague address desire assumption sector long speed against hand significance hell winner street ago influence that bone individual recover previously investigate bird eye rest current division priority vary distinction victim simple ensure religion document deputy trust believe western claim can develop whole otherwise important theatre more count offence necessarily from seat leadership exercise emerge city source several event recommend door benefit element
Anonymous Profile
Anonymous answered
I have written a post on how to create a custom header file. Hope this posts also helps.

What can be done is all the header files can be put into one file and then the new header file can be included. But remember this is going to cost you a lot of memory !!
Azhar Mehmood Profile
Azhar Mehmood answered
You can include a header in your project by simply giving the name of a variable in the directories or libraries a program uses. For example; in C write the names of header file like #include "Header File Name".
John Nawrocki Profile
John Nawrocki answered
This depends on your compiler and development environment. The c++ compiler from Microsoft allows the inclusion of pre-compiled headers (/YX compiler option). I am not sure about others. For more info check out:
Mohsin Hijazee Profile
Mohsin Hijazee answered
Well, automatically inclusion is a vague term. However, custom is that you will create a file named as "allheaders.h"

in allheaders.h, you would be including all other files that you need like this:

Include more headers if you need...

Then you only need to include "allheaders.h" in your other files and all other files will be automatically included.

Answer Question