as

Tuesday, 11 November 2014

Compiling and Executing C programs

Compilation and linking of the c program involves below steps.
  1. Pre processing – Macro substitution, including of header files.
  2. Compilation – generated assembler code.
  3. Assembly – creates object file.
  4. Linking – creates executable file by linking library code.

Turbo C compiler

Figure 1-Compiling and Executing the program in turbo C

  1. We can compile c programs using turbo c compiler or Microsoft visual C++.
    To compile, build and execute C program in Turbo, you can press ctrl+F9 key combination.
    To compile, build and execute C program in Visual C++, you can press ctrl+F5 key combination.
    Below image shows how turbo IDE looks like.

    Typical phases of C program execution are given in below diagram. The sample.c file contains the source code. After compiling the sample.c, new file is created called sample.obj. This is a intermediate machine code generated by compiler. This is also called as an object file. After compiling the c file, we link the obj file and final exe file is created which can be used to execute the c program.

    GCC compiler in windows.

    To compile the program using GCC compiler, use below command from command prompt in windows.
    > Gcc abc.c
    After compiling the program, a.exe file is created which can be used to execute the c program.
   > a



No comments:

Post a Comment

Leave your valuable feedback. Your thoughts do matter to us.

Sponsored Links

Popular Posts

Comments

ShareThis