C Program - How to Execute

<<Previous

Next >>





There are 3 steps involved to execute a program that are:

  • Creating a C program
  • Compilation and linking a C program
  • Executing a C program

Creating a C Program

C program should be written in a text file or C editor or IDE. There are multiple Editors and IDE for every Operating System.

C program you write is called the source code. This file is saved with the default extension " .c ". For example " sample.c ".

Compilation and Linking C program using gcc compiler

  • During compilation, the source program is translated into an object program. This translated program is stored in another file, which has the same name as the source program, with .obj extension.
  • During linking, it links other files and program which is required for our program. For example:
    • if we used the pow() function in our program, then the object code of this function should be brought from the math.h library and linked to our main() program.

    There are various compilers in the market. The Popular C compiler is gcc. However, gcc compiler can not run directly on windows. You need to install Cygwin to run the gcc compiler. Once installed, you can run

    gcc <program_filename.c> 
    .

    This compiles C program and creates .obj file and .exe file. For example, sample.c source file generates sample.obj and sample.exe files

    Executing a C program

    After compilation, You can run the program by simply typing the executable file name sample.exe

    sample.exe

    You can also run the program by simply typing the file name without extension sample

    First Sample Program

    
    #include<stdio.h>
    
    int main() /* main function */
    
    {
      printf(" hello word ");
      return 0;
    }
    
    

    Detailed Step by Step Instructions to get your Windows Environment Ready for C Progamming


    If you are using Windows, Please refer to the section for detailed instructions on setting up C environment:

    Install gcc Compiler on Windows, gcc in Cygwin, Codeblocks, Compile and Run

    << Previous

    Next >>




strcat() - String Concatenation        strcmp() - String Compare


strcpy() - String Copy        strlen() - String Length














C Program - How to Execute

<<Previous

Next >>





There are 3 steps involved to execute a program that are:

  • Creating a C program
  • Compilation and linking a C program
  • Executing a C program

Creating a C Program

C program should be written in a text file or C editor or IDE. There are multiple Editors and IDE for every Operating System.

C program you write is called the source code. This file is saved with the default extension " .c ". For example " sample.c ".

Compilation and Linking C program using gcc compiler

  • During compilation, the source program is translated into an object program. This translated program is stored in another file, which has the same name as the source program, with .obj extension.
  • During linking, it links other files and program which is required for our program. For example:
    • if we used the pow() function in our program, then the object code of this function should be brought from the math.h library and linked to our main() program.

    There are various compilers in the market. The Popular C compiler is gcc. However, gcc compiler can not run directly on windows. You need to install Cygwin to run the gcc compiler. Once installed, you can run

    gcc <program_filename.c> 
    .

    This compiles C program and creates .obj file and .exe file. For example, sample.c source file generates sample.obj and sample.exe files

    Executing a C program

    After compilation, You can run the program by simply typing the executable file name sample.exe

    sample.exe

    You can also run the program by simply typing the file name without extension sample

    First Sample Program

    
    #include<stdio.h>
    
    int main() /* main function */
    
    {
      printf(" hello word ");
      return 0;
    }
    
    

    Detailed Step by Step Instructions to get your Windows Environment Ready for C Progamming


    If you are using Windows, Please refer to the section for detailed instructions on setting up C environment:

    Install gcc Compiler on Windows, gcc in Cygwin, Codeblocks, Compile and Run

    << Previous

    Next >>






strncat() - String n Concatenation        strlwr() - String Lower       

strncmp() - String n Compare       strncpy() - String n Copy