By Dan Gookin

Beginning C language programmers tend to misunderstand the purpose of the header file. Don’t confuse the header file with the library. They’re two separate things.

The header file is merely an extension of your code. It typically contains definitions, prototypes, constants, and perhaps a few macros. It’s just text. In fact, it’s also optional. Consider the following code:

int puts(const char *s);
int main()
{
    puts("Don't bother me now, I'm busy. ");
    return(0);
}

This chunk of code compiles. It runs. It works. Yet it doesn’t contain the traditional first line of C code:

#include <stdio.h>

The stdio.h file includes the prototype for the puts() function. That’s the only reason to include the file in the code. So rather than include it above, the programmer simply copied the prototype from stdio.h and pasted it into his code. The result is that the code compiles the same without the header file.

The library file contains the actual programming gears that make the functions work. So somewhere in the standard C library is the code that controls the puts() function, by sending its argument to standard output. This process still takes place with the code in in this article, when you either build the project in Code::Blocks or link it in another manner.