Compute the difference between two time_t types.
This function is compatible with the following targets:
|
|
#include <time.h>
double difftime(time_t t1, time_t t2);Parameters:
Parameters for this facility are:
difftime() returns the difference of t1 minus t2 expressed in seconds.
#include <time.h>
#include <stdio.h>
int main(void)
{
time_t t1, t2;
struct tm *currtime;
double midnight;
time(&t1);
currtime = localtime(&t1);
currtime->tm_sec = 0;
currtime->tm_min = 0;
currtime->tm_hour = 0;
currtime->tm_mday++;
t2 = mktime(currtime);
midnight = difftime(t1, t2);
printf("There are %f seconds until midnight.\n", midnight);
return 0;
}
Output:
There are 27892.000000 seconds until midnight.
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000