Headers


The Pre-Processor's main use, you'll find, is in including headers. What are they? Headers are like units in Turbo Pascal for MSDOS. The idea is that whenever you want to call functions that are built into the language (like printing out to the screen), you #include the file that defines these functions. In this tutorial, we'll only be using these header files:

Header Name      Use

iostream.h       Printing out to the screen and reading the keyboard
math.h           Math functions, like square roots and logarithms

These files are called system headers, because they are not just files you created, they are part of the compiler. To #include them, you put them in between a < and a >; iostream.h would be included by saying "#include <iostream.h>". This tells the Pre-Processor that you want it to look where it keeps the compiler's system headers, and not where you keep your personal files.

So let's try including both of them in a file:

#include <iostream.h>
#include <math.h>

Pretty easy, eh? Notice that each one is on it's own line. This is a must, because it's very important that the # be at the very beginning of each line you want to use it in.


Table of Contents

Hello, World! | The Pre-Processor | Headers | cout: The Black Box
More Wonders of cout | cin: cout's evil twin | Exercises