How to Compile and Run a C program in Linux?
Do you want to know how to code, compile and execute C Program in Linux platform? Then you are at right place. In this tutorial I will show you how to write and run C Program in Linux terminal.
How to write & save C Program In Linux Terminal ?
Start/Open/Go to Linux Terminal and type
In the above screenshot I have given filename as tutorial.c
The Vi Editor will open.
Press I to insert text and start writing the C Program in it.
After coding it.Just press Esc button and type
Here :wq specifies save and exit.
How to Compile C Program in Linux Terminal?
The next step after coding is compilation part.To compile C Program type the following in Terminal,
gcc -o h Filename.c
If you face any error again enter into text editor,
after fixing the error press Esc button and type
Now execute the program to see the Output type
The output of the program will be displayed.To know more about commands used in VI editor checkout our next tutorial.