I'm looking to get the current time as an int. How can I do this?
I'm looking to get the current time as an int. How can I do this?
Hope problem is solved...!Code:#include <stdio.h> #include <dos.h> int main(void) { struct time t; gettime(&t); printf("The current time is: %2d:%02d:%02d.%02d\n", t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund); return 0; }
One day you will ask what more important to you..
I will say my life..
and You will leave me with even knowing
that
You are my Life (L)
>>Hope problem is solved...!
That's not a portable solution though. Best stick with vVv's version, or you may end up wondering why gettime() isn't found on your compiler.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
one way is to assign the time values to ints hours, mins and secs and write macros to print them in the ways you want. You can then put this into a header file and just call your macro print_time_hms
hth
Monday - what a way to spend a seventh of your life
... but then if you want to do any time calculations, like mytime+300 to add 300 seconds, it becomes a bit of a chore, compared to the standard functions. I suppose it comes down to whatever the programmer wants to do with the data.Originally posted by iain
one way is to assign the time values to ints hours, mins and secs and write macros to print them in the ways you want. You can then put this into a header file and just call your macro print_time_hms
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]