STRUCTURE OF A GOOD 'C/C++' PROGRAM
Labels:
C/C++
There are certain basic aspects that should be kept in mind; such as the format of the code, indentation, comments, smart variables etc..
As for the basic layout, here is a tip:
1> Documentation:
created on: 22 sept-2005, by:urjit */
2>Linking of files and Inclusion:
This section should be used to link to all header files, external files and the library functions. Macros could also be placed in this section.
Example: #include
#include
define PI 3.14
3>Main program:
This section should ideally contain the classes (in case of C++), global variables, filestreams, and the body of the main( ) function, containing all the sub-functions, local variables, objects etc..
4>Functions and extra comments:
This section should contain the extra information and notes about debugging if required (untill the code is perfected), other functions that are to be used in the main program (for defining the functions here, they have to be declared above their control entry; i.e., generally above main).
This should contain the objective of the program, the creator's name and date if neccessary and other details about the program. It should be in the form of a multi-line comment.
Example: /* Program to add two numbers.created on: 22 sept-2005, by:urjit */
2>Linking of files and Inclusion:
This section should be used to link to all header files, external files and the library functions. Macros could also be placed in this section.
Example: #include
define PI 3.14
3>Main program:
This section should ideally contain the classes (in case of C++), global variables, filestreams, and the body of the main( ) function, containing all the sub-functions, local variables, objects etc..
4>Functions and extra comments:
This section should contain the extra information and notes about debugging if required (untill the code is perfected), other functions that are to be used in the main program (for defining the functions here, they have to be declared above their control entry; i.e., generally above main).
0 comments:
Post a Comment