Name
difftime
Synopsis
Calculates the difference between two arithmetic time values
#include <time.h> doubledifftime
( time_ttime2
, time_ttime1
);
The difftime()
function
returns the difference between two time values,
time2
− time1
,
as a number of seconds. While difftime()
has the return type double
, its arguments have the type
time_t
. The time_t
type is usually, but not
necessarily, defined as an integer type such as long
or unsigned
long
.
A common way to obtain the argument values passed to difftime()
is by successive calls to the
time()
function, which returns
the current time as a single arithmetic value.
Example
See the sample program for clock()
in this
chapter.
See Also
asctime()
, ctime()
, gmtime()
, localtime()
, mktime()
, strftime()
, time()
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.