Lesson Zero
The Program That Does Nothing
A C Language Program consists of functions. C functions consist of four parts.
The name, the arguments and the definition, called the body of the function.
There is also the return value. If the return value is not specified, it defaults
to void. In order for a program to be runnable it must have one function named main.
Here is the program that does nothing:
main () {}
Typically you would do something more like this:
int main () {return(0);}
The int is the type of the return value for function main. This means the shell running
main gets back an integer value from your program when it is done running. The problem
here is that returning a zero is doing something. Lesson Zero is the program that does
NOTHING.
So you open a file with a name ending in .c write "main () {}" into it and save it.
The compiler is named cc so you type cc and your file name. For example if your
file is named nothing.c you would type "cc nothing.c"
The default output is a.out so if you type ./a.out your program should "do nothing"
and the exit not returning anything because our return value is void.
If you can do this without getting an error your program should run and the shell
should give you a new prompt. Our function hasfour parts, the woid return value is
invisible in the program file text because we are using the default. The first part
you see is the function name "main" The next part you see "()" is the arguments.
There are none to the program that does nothing. The final part is the function body.
It is empty. When the function is called, It begins with the first "{" and ends
with the final "}".
So go ahead and make a file, put main(){} in it and compile it using cc and run it
./a.out
Lesson One