I was wondering if there was a function to return the system time, I just wanted to make a simple alarm clock program that would go off at a certain time.
Thanks,
Ash
Printable View
I was wondering if there was a function to return the system time, I just wanted to make a simple alarm clock program that would go off at a certain time.
Thanks,
Ash
Hi
Do you want something like this?
And also, if you are using a UNIX like system (like Linux)Code:#include <stdio.h>
#include <time.h>
int main()
{
time_t s;
time(&s);
printf("%s",ctime(&s));
return 0;
}
using "man -K time.h" (which seraches for the manual pages including the phrase "time.h") may help you.
Thanks much!
Also I was hoping you could tell me exactly how that works, and a way to make it so that I could make it go off at a certain time if possible. Sorry to ask, but google wasn't much help, and I didn't have much luck searching these forums either.
Thanks,
Ash
Hi
What i did in the above code is getting the number of elapsed seconds from 0:00:00 Jan 1, 1970 by calling time() and then storing it into s which is of type time_t.
Then the ctime() function converts the time_t value into a human readble nice format and returns a pointer to a character string.
As I wrote in previous message, if you are using a UNIX based system "man ctime" and "man 2 time" commands will give you much information.
If you are not using a UNIX based system (:P), see the links below :
http://man.linuxquestions.org/?query...ction=2&type=2
http://man.linuxquestions.org/?query...ction=0&type=2
Oh, ok thanks. i'm not using UNIX, just winxp :)
Time.h functions are standard, so any old manual page should be good enough for basic usage at least.