Header files serve as the interface between your program and the libraries supplied by the C compilation system. Because the functions that perform standard I/O often use the same definitions and declarations, the system supplies a common interface to the functions in the header file stdio.h. If you have definitions or declarations that you want to make available to several source files, you can create a header file with any editor, store it in a convenient directory, and include it in your program as described in the first part of this chapter.
Header files traditionally are designated by the suffix .h, and are brought into a program at compile time. The preprocessor component of the compiler interprets the #include statement in your program as a directive. The two most commonly used directives are #include and #define. The #include directive is used to call in and process the contents of the named file. The #define directive is used to define the replacement token string for an identifier. For example:
#define NULL 0defines the macro NULL to have the replacement token sequence ``0''. See ``C language compiler'' for the complete list of preprocessing directives. The most commonly used .h files are listed in ``Header files'' to illustrate the range of tasks you can perform with header files and library functions. When you use a library function in your program, the manual page tells you which header file, if any, needs to be included. If a header file is mentioned, it should be included before you use any of the associated functions or declarations in your program. Put the #include right at the top of a source file.
|float.h||floating point limits|
|limits.h||other data type limits|
|time.h||date and time|