time_t t;
printf("%f\n",time(&t));
it throws "Can not print float number"
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));
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.