/* You could use counter as an index to a character array instead of a big clunky repetitive switch. If you have a char *spinner = "|/-\\";, spinner[0] will be "|", spinner[1] will be "/", etc. char *spinner = "|/-\\"; printf("\b%c", spinner[counter]); is going to print the common backspace character and the correct "spinner symbol" for each value of counter. The spinner variable does not need to be declared because it's a string literal: printf("%c", "|/-\\"[counter]); can be used instead. */ #ifdef _WIN32 #include #define sleepThr(x) Sleep(x) #else #include #define sleepThr(x) usleep((x) * 1000) #endif #include #define INTERVAL 200 int main() { int counter; while (1) { for (counter = 0; counter < 4; counter++) { printf("\b%c", "|/-\\"[counter]); fflush(stdout); sleepThr(INTERVAL); } } return 0; }