Header Files

Various library functions are available in C and C++ in the form of header files. A hheader file is a file containing a list of all the functions and structures that will be used by a file ( for C++, classes and methods).

Header files provide function prototypes and declarations for library functions. Data types and constants used with the library functions are also defined in them.

In order to include the required header files in the program, angle brackets '< ' and '>' are used. the angle brackets prompt the C++ compiler to search for the header file in its include directory.

Header files are also known as library files. Each function library has a corresponding header file with an extension 'h' . When a standard function is used in a program, the header file with this function must be included in the program by the preprocessor directive include.

The syntax for including a header file in a program is:

#include < name of the header file >

For example:

# include <conio.h>

Some of the C++ header files are discussed below:

stdio.h

This is a standard C library for input/output with streams. This header file contains the function prototypes of standard I/O functions. In C++, stdio.h is automatically included wen the header file iostream.h is reffered to. When a program that includes stdio.h begin its execution, three predefined standard I/O streams are opened. These are stdin.h, stdout.h and stderr.h.

Streams are an sbstractions used in C and C++ for input output operations through I/O devices based on characters like files, keyboard, printer, screen and I/O ports.

Buffer

The buffer is a property of I/O stream. a buffer is a block of memory where data is accumulated before being physically read from or sritten to the file. Buffering causes I/O operations with the stream to be faster because buffers are faster than phusical devices like disks or ports. A stream can also be un-buffered so that the data is directly read or writen to the device.

String.h

This standard C library is used to manipulate strings. this header file contains the function prototypes of string functions. It declared numerous string manipulation and memory manipulation functions.

the various functions contained by string.h can be divide into three groups- str, strn and mem. Functions starting with the characters 'str' (strcat, srcmp for instance) operate on strings which terminate by a null character. Functions starting with 'strn' operate on strings of specified length. Functions starting with 'mem' operate on the arrays of data of specified length.

math.h

This is a standard C library for mathematical operations. this header file contains the function prototypes of functions required for algebric and trignometrical functions. It also has prototypes for math error handlers.

stdlib.h

this is a general purpose standard c library, containing functions for memory allocation, process control, conversions, search/sort and mathematical opeartions.

ctype.h

This header file contains function prototypes for character classification and character conversion functions.

iostream.h

This header file contains prototypes for basic C++ streams I/O routines.

iomanip.h

This header file contains prototypes for C++ streams I/O manupulators.

HOME LEARN

HOME LEARN C++ PREVIOUS NEXT