header file

Header File: A header file is a file containing C declarations and macro definitions to be shared between several source files. Header can be the system header file or it can be created by the users.

Syntax for system Header Files:

#include <file>

Example:

#include <stdio.h>

Explanation:

It searches for a file named ‘stdio.h’ in a standard list of system directories

Syntax for User defined Header Files:

#include “file”

Explanation:

It searches for file name ‘file’ in the directory containing the current file.

Example(Actual implementation is some how different where header file only contains the declarations)

Create a header file demoheader.h, that contains add() function.

Main program in demo.c

 Output:

Addition of two number is : 30

Explanation:

The complier will see the same token stream as it would, if demo.c read.

 Note:

A header file is a file with extension .h

To use header file in the program by including it with the C preprocessing directive #include