Skip to content

Instantly share code, notes, and snippets.

@StefanoBelli
Last active July 3, 2018 12:00
Show Gist options
  • Save StefanoBelli/0397ebe8bfb4350d0021f92fdc64f281 to your computer and use it in GitHub Desktop.
Save StefanoBelli/0397ebe8bfb4350d0021f92fdc64f281 to your computer and use it in GitHub Desktop.
Wasting time...
#include <stdio.h>
#include <ctype.h>
#define LOAD_INDICATOR(x_ch_ind) \
x_ch_ind = (x_ch_ind == '\\') ? '|' : \
(x_ch_ind == '|') ? '/' : \
(x_ch_ind == '/') ? '-' : \
(x_ch_ind == '-') ? '\\' : '-'
void print_loading_text(char* str, size_t len) {
static size_t pos = 0;
static char loadind = '\\';
if(str == NULL) {
pos = 0;
loadind = '\\';
return;
}
if(pos)
str[pos-1] = tolower(str[pos-1]);
if(pos == len)
pos = 0;
str[pos] = toupper(str[pos]);
pos++;
printf("[WAIT] %s... %c\r", str, loadind);
fflush(stdout);
LOAD_INDICATOR(loadind);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment