printf
, scanf
, and the other standard library functions are provided as part of the implementation.
A C implementation is made up of several components. The compiler is just one of them. The library is another; it consists of headers (commonly provided as source files like stdio.h
) and some form of object code files containing the code that actually implements the library functions.
The header stdio.h
only declares these functions; it doesn't define them. The declaration of printf
is something like:
int printf(const char *format, ...);
The definition of printf
is the code that actually does the job of parsing the format string, accessing the arguments, and sending the formatted output to stdout
. That's typically (but not necessarily) written in C and provided as some kind of linkable object code.
For some C implementations, the compiler and the library are provided by the same organization. For others, they might be provided separately (for example MinGW combines the gcc compiler with Microsoft's library).