One source file should contain a set of (preferably close) related functions. It should provide a consistent set of services for functions outside the source file.
The source file must have an associated header that declares the services provided by the source code. (Exception: the only source file containing main() and not providing the functions used by other files does not need a header file.)
Other files that use these features include a header. The file that defines the function also includes a header to make sure the definitions match the declarations.
In general, it is a good idea for the source file to include a header first; this ensures that the header can be used as "standalone". That is, if any other source file should use the header services, it can include the header without worrying about which of the other headers should have been included first.
source share