-2

time_t t;

printf("%f\n",time(&t));

it throws "Can not print float number"

2 Answers2

1

You may try

#include <stdlib.h> printf("%jd\n", (intmax_t) time(NULL));.

Polluks
  • 525
  • 2
  • 8
  • 19
0

Get Current Date

time_t data type depends on your platform. To solve this issue, you can try to cast it to long long. And directly print it:

printf("%lld\n", (long long) time(NULL));

Measure time taken by a function or process

If you want to calculate the time of a process or a function create a clock_t variable and calculate the difference:

clock_t t; 
t = clock(); 
myfunction(); 
t = clock() - t; 

Note that t is the measured time value here.

isydmr
  • 649
  • 7
  • 16