| C Tutorial | header file vs c file | |||
|
main() Multiple Files Prototypes Preprocessor #define #include foo.h vs foo.c #if Multiple #includes -- #pragma once Assert
|
foo.h vs foo.c The universally followed convention for C is that for a file named "foo.c" containing a bunch of functions...
• A separate file named foo.h will contain the prototypes for the functions in foo.c which clients may want to call. Functions in foo.c which are for "internal use only" and should never be called by clients should be declared static.
• Near the top of foo.c will be the following line which ensures that the function definitions in foo.c see the prototypes in foo.h which ensures the "prototype before definition" rule above. #include "foo.h" // show the contents of "foo.h" // to the compiler at this point
• Any xxx.c file which wishes to call a function defined in foo.c must include the following line to see the prototypes, ensuring the "clients must see prototypes" rule above. #include "foo.h" Want To Know more with Video ??? Contact for more learning: webmaster@freehost7com |
|