The steps involved in building a C program are:
- Create a program by using any text editor and the file is stored with extension as .c.
- Next the program is compiled. There are many compilers available like GNU C compiler called as gcc, Sun compiler, Borland compiler which is popular with PC system and so on. Lots of options are available for compiling. The command used for compilation is
cc name of the file.c.
At this stage errors like typing mistake, mistake in key words, syntax usage errors will be detected and will displayed which the programmer can correct. But a programmer must note that compiler cannot detect logical errors.
- After this process the compiled or executable code by default gets stored in a . out. If one wants to store the executable code in a filename instead of in a . out this can be done by using the -o option along with [an error occurred while processing this directive] cc as follows:cc -o sample sample.c
- After compilation the program is executed by using the executable file name. At this stage runtime errors or incorrect output due to logical or functional errors may be seen in output which is corrected further and the process is repeated until the correct result is displayed.