what is header file in c

11 months ago 20
Nature

A header file in C is a file with the extension ".h" that contains C function declarations and macro definitions to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that come with the compiler. Standard header files contain the libraries defined in the ISO standard of the C programming language. They are stored in the default directory of the compiler and are present in all the C compilers from any vendor. Header files serve two purposes: they contain function prototypes or function declarations, and they contain constants, macros, system-wide global variables, and function prototypes. Including a header file is equal to copying the content of the header file, but it is not a good idea to copy the content of a header file in the source files, especially if we have multiple source files in a program. A simple practice in C or C++ programs is that we keep all the constants, macros, system-wide global variables, and function prototypes in the header files and include that header file wherever it is required. We request to use a header file in our program by including it with the C preprocessing directive #include.