The anatomy of a program
We have some compiler preprocessor commands. This includes various #include files. Then comes the main function. Some name can also be given to the main function. Then, we have the variable declarations used in the main code. Then we have sub-functions.
main function name()
In the previous example, we had the sub functions as a separate files. But you can also include them it into the main code. In this case, in one file, we can have main program of the main function and sub-functions or separately. It is a good idea to have the sub-functions separately. We also compile them n link them separately.
It is always safer to do that. For large programs, it is good to have sub functions separately. Sub function has also the same structure like main function. It might have some arguments which would be passed into it. Then comes argument declaration. Then we have some variable declarations which is only private to sub functions only. We will see the examples of these.
Before going to the example, let us look at each one these in detail.
The standard C compiler has four filters. The first one is known as the preprocessor. This part handles the inclusion of files mentioned using the #include command, definition of constants, macro definition etc.
The second filter checks the language statements, generates a symbol table and reports any errors found.
The third part generates the code and a fourth filter optimizes the code for better performance
The fourth one optimizes the function. It improves the code and modifies the code and so that it runs faster. This is an optional part of the compiler.