C Programming Language |
malloc |
calloc |
memset |
memcpy |
memory |
strcpy |
string |
strtok |
isalnum |
cctype |
errno |
cfenv |
clock |
difftime |
mktime |
ctime |
fprintf |
fscanf |
printf |
scanf |
stdio |
math |
defined in header file time.h
double difftime( time_t t1, time_t t0);
difftime() function returns the number of seconds elapsed between time 't1' and time 't0', returned as a double.
The two times are specified in calendar time, which represents the time elapsed since the EPOCH (00:00:00 on January 1, 1970, Coordinated Universal Time (UTC)).
Parameter | Description |
---|---|
t1 | instance of time_t for start of the time. |
t0 | instance of time_t for end of the time. |
double value, contains difference of two times in seconds (t1 - t0).
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// gcc -o difftime_prg difftime_prg.c
// ./difftime_prg
int main ()
{
printf("started program %s-%d\n", __FUNCTION__, __LINE__);
time_t t1, t0;
time( &t1);
printf( "start-time t1=%ld\n", t1);
int w = 0;
while( w < 5)
{
usleep(999999);
w++;
}
time( &t0);
printf( "end-time t0=%ld\n", t0);
printf( "difftime=%f\n", difftime( t0, t1));
return EXIT_SUCCESS;
}
started program main-10
start-time t1=1552970460
end-time t0=1552970465
difftime=5.000000
zalloc is a third party library
posted on 2018-12-12 20:46:30 - C Programming Language Tutorials
posted on 2017-12-29 22:52:47 - C Programming Language Tutorials