[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


difftime

Compute the difference between two time_t types.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <time.h>
double difftime(time_t t1, time_t t2);
Parameters:

Parameters for this facility are:

t1  
time_t  
A time_t variable to compare  
t2  
time_t  
A time_t variable to compare  

Return:

difftime() returns the difference of t1 minus t2 expressed in seconds.

Example of difftime usage.:
#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