skynet2302

Indicador de progreso en lenguaje C

Oct 11th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. //Indicador de progreso en lenguaje C
  2. //Compilado en GCC 5.3.0
  3. //Fecha y hora: 11-10-2016 20:35 hora central de México
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <unistd.h>
  8. #include <time.h>
  9.  
  10. int main (int argc, char **argv)
  11. {
  12. const char s[] = "-\\|/-\\|/";
  13. const short operations = 300;
  14. short i, pos=0;
  15.  
  16. for(i=0; i<=operations; i++)
  17. {fprintf(stdout,"Progreso: %c\r",s[pos]);fflush(stdout);pos++;if(pos>=strlen(s))
  18. pos=0;
  19. sleep(1);
  20. }
  21. return EXIT_SUCCESS;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment