Skip to content

Instantly share code, notes, and snippets.

@diegozr1
Created September 18, 2017 00:29
Show Gist options
  • Save diegozr1/118bfc247bce5aa4d85c29e76dda20fa to your computer and use it in GitHub Desktop.
Save diegozr1/118bfc247bce5aa4d85c29e76dda20fa to your computer and use it in GitHub Desktop.
Loading simulation in c
#include <stdio.h>
#include <unistd.h>
int main()
{
char bar[] = {
'-',
'\\',
'|',
'/'
};
unsigned int i;
int speed = 40000; //miliseconds
for (i = 0; ; ++i) {
printf("Loading ... %c \r", bar[i % sizeof(bar)]);
fflush(stdout); // clean
usleep(speed); // resets execution
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment