Created
November 30, 2021 10:33
-
-
Save Treebug842/41952fecfb8006137da352ed888b121f to your computer and use it in GitHub Desktop.
Simple Loading bar in c++
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
#define COUNTER_TIME_S 10 | |
#define DELAY_MS 1000 | |
#include <windows.h> | |
#include <iostream> | |
void clearScreen(int characterLength) { | |
for (int i=0; i<characterLength; i++) { | |
std::cout << "\b"; | |
} | |
} | |
int main() { | |
for (int i=0; i<COUNTER_TIME_S; i++) { | |
std::cout << "["; | |
for (int j=0; j<i; j++) {std::cout << "#";} | |
for (int j=(COUNTER_TIME_S-i); j>0; j--) {std::cout << " ";} | |
std::cout << "]"; | |
Sleep(DELAY_MS); | |
clearScreen(COUNTER_TIME_S+2); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment