Image may be NSFW.
Clik here to view.
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. Image may be NSFW.
Clik here to view.
1. Goto Linux Terminal.
2. Type Vi Filename.C
Image may be NSFW.
Clik here to view.
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.
Image may be NSFW.
Clik here to view.
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. Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
That’s it Image may be NSFW.
Clik here to view. 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. Image may be NSFW.
Clik here to view.
Output :
1000000000, Sun Sep 9 01:46:40 20012147483647,
Tue Jan 19 03:14:07 2038-2147483648,
Fri Dec 13 20:45:52 1901
Source Code taken from here