skynet2302

Indicador de progreso en lenguaje C 2

Oct 11th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 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 short operations = 300;
  13. float inc = 100.0f / ((float)operations-1.0);
  14. float progress = 0.0f;
  15. short i, pos=0;
  16.  
  17. for(i=0; i<=operations; i++) {
  18. progress+=inc;
  19. fprintf(stdout, "Progreso: %d\r", (int)progress); fflush(stdout);
  20. sleep(1);
  21. }
  22. return EXIT_SUCCESS;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment