Header files are used by programmers. A header file contains definitions of constants and macro functions or inline functions.
A program can contain symbols and mnemonics that makes a program more generic, readable and understandable. These symbols are defined in a header file. Then at the top of a program a statement is written to include the header file in this file. This inclusion is done by a preprocessor or a compiler or interpreter.
Examples: stdio.h, math.h
If we want to use IO (input output) functions like printing, reading from keyboard, then we need to include stdio.h.
We can write also a header file named "myhdr.h" , containing for example:
#define N 10 #define M 20
Then we can write inside a program file : #include "myhdr.h"
Then we can use the constants N and M inside the program without having to define them. The advantage is that we can include one header file in many programs, that make use of the constants and functions.
For simplest answer.. .. A header file is a file with extension .h which 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 comes with your compiler.
Answers & Comments
Verified answer
Header files are used by programmers. A header file contains definitions of constants and macro functions or inline functions.A program can contain symbols and mnemonics that makes a program more generic, readable and understandable. These symbols are defined in a header file. Then at the top of a program a statement is written to include the header file in this file. This inclusion is done by a preprocessor or a compiler or interpreter.
Examples: stdio.h, math.h
If we want to use IO (input output) functions like printing, reading from keyboard, then we need to include stdio.h.
We can write also a header file named "myhdr.h" , containing for example:
#define N 10
#define M 20
Then we can write inside a program file :
#include "myhdr.h"
Then we can use the constants N and M inside the program without having to define them. The advantage is that we can include one header file in many programs, that make use of the constants and functions.
Verified answer
For simplest answer.. ..A header file is a file with extension .h which 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 comes with your compiler.