Sunday 18 July 2010

Header Files

Header files are also known as library files. Header Files performs two things:

The definitions and prototypes of functions being used in a program.
Simply put, commands that you use in C programming are actually functions that are defined from within each header files.

Each header file contains a set of functions.

Example:
stdio.h is a header file that contains definition and prototypes of commands like printf() and scanf().

Why is it that not all header files are declared in every C program?

The choice of declaring a header file at the top of each C program would depend on what commands/functions you will be using in that program.
Since each header file contains different function definitions and prototype, you would be using only those header files that would contain the functions you will need.

Declaring all header files in every program would only increase the overall file size and load of the program, and is not considered a good programming style.


You may like the following posts:
Macros
Preprocessor Directives
Functions
 Predefined functions

No comments:

Post a Comment