cprocessoutputminixtime.h

How do I show the time of a process in minix, using the library time.h?


time_t t;

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

it throws "Can not print float number"


Solution

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