how to compile .c extension file plz give me commands

Asked by anshul jain

when we make program in linux(in C or C++)
      we go in application then terminal then we make dir and then make file under that directory and save as (.c)extension and after it we write the program coding then after that what should be done to compile the file

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gnome-terminal Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Ralph Janke (txwikinger) said :
#1

You can compile it with the gcc command if you have installed the compiler package:

    gcc -o filename filename.c

Revision history for this message
Paolo Sammicheli (xdatap1) said :
#2

if you have a simple C program, to compile it you have to use gcc. For example, to compile example.c type in terminal:

$ gcc example.c -o example.run

Further information with

$ man gcc

Btw, C programs normaly have a lot of modules and link to library. To compile everythings in a single shot you have to use "make" command.

$ man make

I suggest you to find a C programmer's guide with google cause is impossible to teach how to program in a support service like this.

Bye

Revision history for this message
popohits (popohits) said :
#3

Hot to compile this program

#include<stdio.h>
int main()
{
 int x,z,r;
 printf("Enter the first number :");
 scanf("%d",&x);
 printf("Enter the second number :");
 scanf("%d",&z);
 r=x+z;
 return r;

}

plz i wanna quick and easy solution
thx alot :)

Revision history for this message
s.arivoli (arivoli) said :
#4

For example if you have a simple C program(named as "exampl.c"), to compile it you have to use gcc. To compile example.c type in terminal:

$ gcc example.c -o example

to run it
$./example

Revision history for this message
s.arivoli (arivoli) said :
#5

For example if you have a simple C program(named as "example.c"), to compile it you have to use gcc. To compile example.c type in terminal:

$ gcc example.c -o example

to run it
$./example

Can you help with this problem?

Provide an answer of your own, or ask anshul jain for more information if necessary.

To post a message you must log in.