Concept

What are preprocessor directives and why are standard libraries included?

ComputerScienceOne / Preprocessor Directives

"The lines,\n\n1 #include <stdlib.h>\n\n2 #include <stdio.h>\n\nare preprocessor directives. Preprocessor directives are instructions to the compiler to modify the source code before it starts to compile it. These particular lines are “including” standard libraries of functions so that the program can use functionality that has already been implemented for us. The first, stdlib.h represents the C standard (std) library (lib). This library is so essential that many compilers will automatically include it even if you do not explicitly do so in your program. Still, it is best practice to include it in your code. The second, stdio.h is the standard (std) input/output (io) library which contains basic input/output (I/O) functions that we can use. In particular, the standard output function printf() is part of this library. Failure to include a library means that you will not be able to use the functions it provides in your program. Using the functions without including the library may result in a compiler error. The .h in the library names stands for “header”; function declarations are typically contained in a header file while their definitions are placed in a source file of the same name. We’ll explore this convention in detail when we look at functions in C (Chapter 18)."

Related Ideas

What are preprocessor directives and why are standard libraries included? | ComputerScienceOne | Bifalgorithm | Bifalgorithm