How would I print a spinning curser in a utility that runs in a terminal using standard C?
I\'m looking for something that prints: \\ | / - over and over in the same pos
Here's some example code. Call advance_cursor() every once in a while while the task completes.
#include
void advance_cursor() {
static int pos=0;
char cursor[4]={'/','-','\\','|'};
printf("%c\b", cursor[pos]);
fflush(stdout);
pos = (pos+1) % 4;
}
int main(int argc, char **argv) {
int i;
for (i=0; i<100; i++) {
advance_cursor();
usleep(100000);
}
printf("\n");
return 0;
}