Date: 2021may11
Update: 2026jul15
Keywords: progress, throbber, wait, command line
Language: C/C++
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; // Restart
printf("%s %c\r", msg, spinner);
fflush(stdout);
}
int main() {
for (;;) {
WaitingSpinner("Waiting for something");
sleep(1);
}
}
Output:

Many other fun choices of characters here:
https://stackoverflow.com/questions/2685435/cooler-ascii-spinners