Programming Tips - C/C++: ASCII Spinner

Date: 2021may11 Keywords: progress, throbber, wait, command line Q. C/C++: ASCII Spinner A. Here is a classic spinner
#include <stdio.h> #include <unistd.h> void WaitingSpinner(const char *msg) { static const char *spins = "|/-\\"; static const char *pSpin = spins; const char spinner = *pSpin++; if (!*pSpin) pSpin = spins; printf("%s %c\r", msg, spinner); fflush(stdout); } int main() { for (;;) { WaitingSpinner("Waiting for something"); sleep(1); } }
Many other fun choices of characters here https://stackoverflow.com/questions/2685435/cooler-ascii-spinners