#include<stdio.h>
#ifdef _WIN32
  #include<windows.h>
  #define PAUSE(x) Sleep(x)
#else
  #include<unistd.h>
  #define PAUSE(x) usleep((x)*1000)
#endif
void
bar( int width )
{
  int jest, powinno_byc, zmiana, i;
  for( jest = 0, i = 0; i <= 100; i++ ) 
  {
    powinno_byc = ((float)width * (float)i) / 100.0f;
    zmiana = powinno_byc - jest;
    while( zmiana-- ) putchar('=');
    jest = powinno_byc;
    PAUSE(10);
  }
  printf("done..\n");
}
int
main( void )
{
  bar( 10 );
  bar( 20 );
  bar( 40 );
  bar( 80 );
  
  return 0;
}
        
        Back to Code Snippets / Powrót do Strzępów Kodu

  






Add a comment: