C Program to Get the Current System Time
Submitted by Srikanth on Wednesday, 16 January 20082 Comments

This program reads the current system time and displays it in the form HH:MM:SS
#include <stdio.h>
#include <dos.h>
#include <dos.h>
int main(void)
{
struct time t;
gettime(&t);
printf(“The current time is: %2d:%02d:%02d\n”, t.ti_hour, t.ti_min, t.ti_sec);
return 0;
}
Popularity: 1% [?]
By using/following this site you agree to our Legal Disclaimer


hi
this program can’t be run on linux as you are using dos.h,
i want a program with same output with date (day month year separately).
awaiting your response,
bye.
program that prints the time is
void main()
{
int hr,min,sec;
for(hr=0;hr<24;hr++);
{
for(min=0;min<60;min++);
{
for(sec=0;sec<60;sec++);
{
sleep(1);
clrscr();
printf("%d%d%d",hr,min,sec);
}
}
}
}
here "sleep(1)" command maintain interval of 1 sec between two print statements.
Leave your response!
EMAIL SECURITY »
What to Do When Your Email Account is Hacked?
How to Recover Hacked Email Accounts?
It can be a real nightmare if someone hacks and takes control of your email account as it may contain confidential information like bank logins, credit card details and other sensitive data. …
HOW STUFFS WORK »
How Antivirus Software Works
Due to ever increasing threat from virus and other malicious programs, almost every computer today comes with a pre-installed antivirus software on it. In fact, an antivirus has become one of the most essential software package for every computer. Even though every one …
HOW-TO GUIDES »
How to Hide Data in Image, Audio & Video Files: Steganography
Ever wondered to know how to hide secret messages in images, audio and video files? Well, in this post I will take you through a concept called steganography using which, it is possible to hide your secret information …
INTERNET SECURITY »
How to Hide Data in Image, Audio & Video Files: Steganography
Ever wondered to know how to hide secret messages in images, audio and video files? Well, in this post I will take you through a concept called steganography using which, it is possible to hide your secret information …
NETWORK HACKS »
How to Hack an Ethernet ADSL Router
Almost half of the Internet users across the globe use ADSL routers/modems to connect to the Internet however, most of them are unaware of the fact that it has a serious vulnerability which can easily be exploited even by a …
Categories