1

I'm trying to print the time in seconds at when the print is executed.

This is what I have:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void printTime(clock_t start){
    clock_t stop = clock();
    double time = (double)(stop-start)/CLOCKS_PER_SEC;
    printf("This is printed at time %f.\n", time);
}

int main(){
    clock_t start = clock();
    sleep(3);
    printTime(start);
    return 0;
}

It would always print the time as 0.000000

FiftySentos
  • 117
  • 1
  • 8

0 Answers0