difftime()



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)).

Parameters
ParameterDescription
t1instance of time_t for start of the time.
t0instance of time_t for end of the time.
Returns

double value, contains difference of two times in seconds (t1 - t0).

example program
#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;
}

program output

started program main-10
start-time t1=1552970460
end-time t0=1552970465
difftime=5.000000



strtok

Split string into tokens

posted on 2019-03-17 20:41:48 - C Programming Language Tutorials


zalloc

zalloc is a third party library

posted on 2018-12-12 20:46:30 - C Programming Language Tutorials


math

posted on 2017-12-29 22:52:47 - C Programming Language Tutorials


Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials