Before getting into the steps let me remind you I am using “Fedora 15”.A newer version of Fedora is available “Fedora 16” you can try it too.So now we are ready to rock and roll.
Go to Application -> System Tools –> Terminal and then click on “ Terminal ”
A terminal window will pop up.
Now we need an editor like “Notepad” in Windows to write our codes.So, to do that we will use the vi editor,a built in text-editor in Linux.
Just type vi followed by name of your C program and hit enter.
“ vi SimpleProgram.c “
A vi editor screen will appear.
Then just press “ i ” on your keyboard to get into the “ insert “ mode.Now we are ready to start coding.
Now let us write a simple program
When you are done with your C coding and want to exit from the vi editor screen just press
“Esc” key and then type “ :wq “ and hit “Enter”.
Now we will again return to terminal screen
Now we will compile and run our “SimpleProgram.c”.To compile just type
“ gcc –o Object_Name C_Program_Name “
“ gcc –o Simple_obj SimpleProgram.c “
After successful compilation a Object file will be created based on your Object Name.In this case
To run your c program just type
“ ./Object_Name “ and hit “Enter”
“ ./Simple_obj “
The Output will be printed on the Screen.
This is what to need to do in order to write and run your C program in Linux.
If you want to know some more commands to start yourself with Linux then just visit the link below
If you have any query then do post a comment.