Last active
July 3, 2018 12:00
-
-
Save StefanoBelli/0397ebe8bfb4350d0021f92fdc64f281 to your computer and use it in GitHub Desktop.
Wasting time...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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