Search code examples
cheaderlibraries

What is the difference between a library file and a header file or are they synonymous?


#include "stdio.h"

#include "file_created_by_me.h"


In the first include there is a library file, in the second include there is a header file, or both can be called as libraries or headers because library and header are synonymous?


Solution

  • Both are header files.

    The first header file provides declarations of some of the functions provided by the C standard library. Therefore, one could say that it is part of the C standard library.

    The second header file probably provides declarations of functions that are defined in other parts of your program. Therefore, it is not part of a library.

    A library generally provides header files so that you can #include them in your program, so that the compiler has the necessary function declarations in order to call the functions in the library. However, the main part of the library, which consists of the actual function definitions, is not imported by the compiler, but rather by the linker.