|
|
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.
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 compilers'' 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 will tell 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.
assert.h | assertion checking |
ctype.h | character handling |
errno.h | error conditions |
float.h | floating point limits |
limits.h | other data type limits |
locale.h | program's locale |
math.h | mathematics |
setjmp.h | nonlocal jumps |
signal.h | signal handling |
stdarg.h | variable arguments |
stddef.h | common definitions |
stdio.h | standard input/output |
stdlib.h | general utilities |
string.h | string handling |
time.h | date and time |
unistd.h | system calls |
Header Files