Home > Article > Backend Development > Header Files in C
A header file in C is a file with a '.h' extension that contains declarations for functions, macros, constants and sometimes data types that can be shared across multiple source files.
Preprocessor Directive is a line in a program that is not a programming statement but actually a command for preprocessor.
For Example:-
#inlude
#define
In this command # is a preprocessor and include is a macro.
There are mainly two types of Header files
1. predefined Header Files
These are the type of header files provided by C standard library which contain declaration for inbuilt functions.
2. User-defined Header Files
These are the type of Header files that a programmer can create and use in there specific projects. Including declarations for functions, macros, constants, and custom data types.
There are Mainly 2 ways to declare header files
For creating a user defined Header file, just create a file with .h file type and some functions inside that file and save it in either your local folder or c language system directories.
To call that header file use the preprocessor directive #include and then name of the header file in double quotes.
And then You can use your own functions from your own header file without creating it inside that program.
The above is the detailed content of Header Files in C. For more information, please follow other related articles on the PHP Chinese website!