Thursday, July 1, 2010

My first C Programming in Linux

I am good in C, C++ programming in windows using visual studio editor, but I don't know how to write, compile and run a C, C++ program in Linux. Just I learned. I like to share that with all.

Open any editor like vi and create a file "hello.c" and write a simple hello world program.
To create a file in using VI editor.
Open Terminal window then type following command to create a file.
vi hello.c
Now press the insert key and type the following program.


#include<stdio.h>
int main()
{
printf("hello world");
return 1;
}



now press type following command to save and exit
:wq
To Compile type the following command
cc hello.c -o hello
To run type the following command
./hello

No comments:

Post a Comment