Friday, January 18, 2013

How to compile C program in ubuntu using gcc

To compile your program using gcc compiler you need to download build essential library
so write on terminal

$sudo apt-get install build-essential

make a file called test.c

write a test C program


  • #include<stdio.h>
  • #include<stdlib.h>
  • int main()
  • {
  • printf("\nHello World\n\n");
  • return(0);
  • }

Save the program and go to the directory in which you have made your test.c


cd test.c

COMPILE 

gcc -Wall -W -Werror test.c -o test

RUN

./test

now your program is running.

No comments:

Post a Comment