Quantcast
Channel: Webminal - Latest topics
Viewing all articles
Browse latest Browse all 484

How to compile C code and execute it?

$
0
0

@laks wrote:

If you know vim/vi editor open a hello.c and save
this content

int main(){
printf("hello linux world!");
return 0;
}

If you don't know how to use vi/vim editor - just type


cat > hello.c (now start typing about program and press ctrl+d to save and quit)

Now you have your first C code. Just try to compile with

gcc hello.c

It will create a filename a.out - To run the binary do

./a.out

! got it?

If you want to create binary with different name just use -o option during compilation,
like

gcc hello.c -o hello

Now you will have a binary named 'hello', execute it as

./hello

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 484

Trending Articles