How should I read a system time in a variable, if I want to pass that time later on to a function? None of the ways I've tried has worked, so I really could use some advice. I'm using Visual C++ 6.0.
Thanks in advance.
Henry
How should I read a system time in a variable, if I want to pass that time later on to a function? None of the ways I've tried has worked, so I really could use some advice. I'm using Visual C++ 6.0.
Thanks in advance.
Henry
What did you try?Code:void foo ( time_t when ); time_t now = time(NULL); foo ( now );
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Well, everything else but that. Appearantly I tried to do it harder than it had to.
Thanks.
Henry
There are other ways to do this with VC++, and a number of useful API functions for manipulating, displaying and calculating with dates and times. Look in the compiler help.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
I am sorry to say, using time_t is poor programming. time_t is 32-bit long, therefore, it only supports up to year 2038, and it does not support daylight saving time. You will kick yourself in the head when a senior guy looked at that code which basically needs to be rewritten if all you use is time_tOriginally posted by Salem
What did you try?Code:void foo ( time_t when ); time_t now = time(NULL); foo ( now );
> time_t is 32-bit long
And when it's redeclared as something bigger, you only have to recompile the code, and the problem goes away for a few more million years
Do you know nothing of writing portable programs?
Originally posted by Salem
> time_t is 32-bit long
And when it's redeclared as something bigger, you only have to recompile the code, and the problem goes away for a few more million years
Do you know nothing of writing portable programs?
well, right now it is not 64-bit yet, and you are programming now, what happens in your program that someone choose a date beyond year 2038 or the data/input by mistake is beyond year 2038, then you get unprecitable results. It is like using uninitalized variable in release build if you know what that will amount to. Your boss don't let you wait till they switch to 64-bit in who knows when.
the previous was my post. And what happens if user adjust window time to year 2050. then your program will act really funny...