
Here are some interesting pieces of the C program shown in figure:
-
#include is known as a preprocessor directive, which sounds impressive, and it may not be the correct term, but you’re not required to memorize it anyhow. What it does is tell the compiler to “include” text from another file, stuffing it right into your source code. Doing this avoids lots of little, annoying errors that would otherwise occur.
-
<stdio.h> is a filename hugged by angle brackets (which is the C language’s attempt to force you to use all sorts of brackets and whatnot). The whole statement #include <stdio.h> tells the compiler to take text from the file STDIO.H and stick it into your source code before the source code is compiled. The STDIO.H file itself contains information about the STanDard Input/Output functions required by most C programs. The H means “header.”
-
int main does two things. First, the int identifies the function main as an integer function, meaning that main() must return an integer value when it’s done. Second, that line names the function main, which also identifies the first and primary function inside the program.
Two empty parentheses follow the function name. Sometimes, items may be in these parentheses.
-
All functions in C have their contents encased by curly braces. So, the function name comes first (main in Item 3), and then its contents — or the machine that performs the function’s job — is hugged by the curly braces.
-
printf is the name of a C language function, so I should write it as printf(). It’s job is to display information on the screen. (Because printers predated computer monitors, the commands that display information on the screen are called print commands. The added f means “formatted,” which you find out more about in the next few chapters.)
-
Like all C language functions, printf() has a set of parentheses. In the parentheses, you find text, or a “string” of characters. Everything between the double quote characters (“) is part of printf’s text string.
-
An interesting part of the text string is \n. That’s the backslash character and a little n. What it represents is the character produced by pressing the Enter key, called a newline in C.
-
The printf line, or statement, ends with a semicolon. The semicolon is C language punctuation — like a period in English. The semicolon tells the C compiler where one statement ends and another begins. Note that all statements require semicolons in C, even if only one statement is in a program or function.
-
The second statement in GOODBYE.C is the return command. This command sends the value 0 (zero) back to the operating system when the main() function is done. Returning a value is required as part of the main() function. Note that even though this command is the last one in the program, this statement ends in a semicolon.
