Do you wish to know howto write, compile and execute C Program in Linux platform? Then you are at right place.In this tutorial I will show you howto code and run C Program in Linux terminal. ๐
1. Goto Linux Terminal.
2. Type Vi Filename.C
In the above screenshot I have given filename as 2038bug.c
3. The Vi Editor will open.
Note:
To know more about commands used in VI editor checkout,
Vim/Vi Editor Commands Cheat Sheet
4. Press I to insert text and start writing the C Program into it.
5. After coding it.Just press Esc button and type :wq
Note:
Here :wq specifies save and exit.
How to Compile C Program In Linux Terminal ?
6. The next step after coding is compilation part.To compile C Program type the following in Terminal,
CC Filename.c
If you had any error again enter into text editor,
Vi Filename.c after fixing the error pressย :wq (Save and exit).
7. Now execute the program to see the Output
Type ./a.out
The output of the program will be displayed. ๐
That’s it ๐ In this tutorial I have simulated a Year 2038 bug or Y2k38 using C Program. The following ANSI C programme when compiled simulates the bug. ๐
Output :
1000000000, Sun Sep 9 01:46:40 20012147483647,
Tue Jan 19 03:14:07 2038-2147483648,
Fri Dec 13 20:45:52 1901
I presume itโs because you have conflicting versions installed perhaps. Dedicated developers are not only good with writing codes and programs, but they also know what the clientโs needs are and offers a greater control over a project. I just installed it from the dmg file and made the appropriate connections in the code and it went fine,its really great.
Thanks a lot.. nice program for beginners.
Thanks .. for this tutorial. It is very useful for beginners. There are basically four steps in writing your first C program : Write, Compile, Execute and Output. Printing hello world string on screen is the first program of most of the new programmers. Here are the steps in details to write your first C programming language program.
First C program to print Hello World
thanks for information
Can you pls tell me the syntax for executing if we are using gedit as the editor.
We absolutely love your blog and find most of your post’s to be exactly I’m looking for. Do you offer guest writers to write content for yourself? I wouldn’t mind writing a post or elaborating on some of the subjects you write concerning here. Again, awesome web log!
i have one doubt..
i installed redhat linux but not run in c programming…cc filename.c i give means bash shell error displayed.. how to run that pls help me… can u send answer to my mail id…
great help…thanks for all this
Actually this is really good post.. Intead of cc i used gcc compiler
Thanks for this How To. Being an old C programmer from way back in the old Borland Turbo C days, and having since moved to Ubuntu, this will get me started programming in Ubuntu.
really good post
imnstalling linux 2day & will ask u regarding de same blog if I need ur assistance
!
gr8 write up
thanks