Mail Archives: djgpp/1996/12/26/10:28:29
On Mon, 23 Dec 1996, Tudor wrote:
> EX:
> ....
> time start,end;
> ....
> gettime(&start);
> .....
> .....
> gettime(&end);
>
> at this point start.ti_min equals end.ti_min and the value is totally
> screwed up.
You didn't post any code (the geek code in the signature doesn't count, I
guess), so I can't tell what's wrong with your program. However, the
small test program below works well for me: it prints two times which
are both reasonable and different from one another. Of course, if I
press a key too quickly, the two times are identical, but that's because
of the inherent 55ms resolution of the PC clock.
Note that the fields of struct time are declared unsigned char. Maybe
you used an incorrect format specifier which made the numbers look like
if they were garbled?
-----------------------------------------------------------------------
#include <stdio.h>
#include <dos.h>
#include <conio.h>
int main(void)
{
struct time start, end;
gettime (&start);
printf ("Start time is %.2u:%.2u:%.2u.%.2u0\n",
start.ti_hour, start.ti_min, start.ti_sec, start.ti_hund);
fputs ("Press any key...", stderr);
while (!kbhit ())
;
gettime (&end);
printf ("\nEnd time is %.2u:%.2u:%.2u.%.2u0\n",
end.ti_hour, end.ti_min, end.ti_sec, end.ti_hund);
return 0;
}
- Raw text -