Advertisement
captainIBM

Timer

Dec 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int timer(long seconds);
  6.  
  7. int main()
  8. {
  9.     long seconds;
  10.  
  11.     printf("Entrez le nombre de secondes \205 patienter :\n");
  12.     scanf("%d", &seconds);
  13.     system("cls");
  14.  
  15.     if(timer(seconds)== 1){
  16.         system("cls");
  17.         printf("temps imparti fini, question suivante \n");
  18.     }
  19. }
  20.  
  21.  
  22. int timer(long seconds){
  23.     while (seconds > 0){
  24.         printf("\rSecondes restantes : %03i", seconds);
  25.         seconds--;
  26.         _sleep(1000); //on attend 1 seconde mais on devra faire un multithread pour géré la réponse et le chrono séparéménetnt
  27.     }
  28.  
  29. return 1;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement