Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7. time_t start, stop;
  8. double seconds;
  9.  
  10. /* leggo il tempo */
  11. start = time(NULL);
  12. printf("start = %ld\n", start);
  13.  
  14. /* attendo 3 secondi */
  15. sleep(3);
  16.  
  17. /* rileggo il tempo */
  18. stop = time(NULL);
  19. printf("stop = %ld\n", stop);
  20.  
  21. /* calcolo la differenza */
  22. seconds = difftime(stop, start);
  23.  
  24. printf("Tempo trascorso = %g\n", seconds);
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement