Advertisement
KDOXG

Timer example

Jan 25th, 2019
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. void delay(unsigned int seconds)
  5. {
  6.     int aux=0;
  7.     int n = seconds * 1024;
  8.     clock_t start_time = clock();
  9.     while (clock() < start_time + n)
  10.     {
  11.         aux=aux;
  12.     }
  13. }
  14.  
  15. void main()
  16. {
  17.     unsigned int contador = 1;
  18.    
  19.     for (; contador >= 1; )
  20.     {
  21.         printf("%d ", contador);
  22.         contador++;
  23.         delay(1);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement