[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


Uses of Header Files

Header files serve two kinds of purposes.

Including a header file produces the same results in C compilation as copying the header file into each source file that needs it. But such copying would be time-consuming and error-prone. With a header file, the related declarations appear in only one place. If they need to be changed, they can be changed in one place, and programs that include the header file will automatically use the new version when next recompiled. The header file eliminates the labor of finding and changing all the copies as well as the risk that a failure to find one copy will result in inconsistencies within a program.

The usual convention is to give header files names that end with `.h'. Avoid unusual characters in header file names, as they reduce portability.


[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]