Skip to content

Instantly share code, notes, and snippets.

@wrosecrans
Created February 4, 2024 22:00
Show Gist options
  • Save wrosecrans/09a8508faead37387ac0d8c49e1aac82 to your computer and use it in GitHub Desktop.
Save wrosecrans/09a8508faead37387ac0d8c49e1aac82 to your computer and use it in GitHub Desktop.
spinny.cpp
#include <iostream>
#include <format>
#include <thread>
int main() {
using namespace std::chrono_literals;
char spinners[] = {'-','\\','|','/', '-'};
for (int i=0; i<1000; i++) {
std::string current_line = std::format("\r{} {} {} {} Hello {} ",
spinners[i%4], spinners[(i+1)%4], spinners[(i+2)%4], spinners[(i+3)%4], i%4 );
std::cout << current_line;
std::this_thread::sleep_for(500ms);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment