Skip to content

Instantly share code, notes, and snippets.

@mlcollard
Last active March 12, 2019 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlcollard/29b30a1951022b878e0c69f0a183d634 to your computer and use it in GitHub Desktop.
Save mlcollard/29b30a1951022b878e0c69f0a183d634 to your computer and use it in GitHub Desktop.
/*
dance.cpp
Single line ASCII dancer who dances forever
*/
#include <iostream>
#include <unistd.h>
useconds_t MOVE_SPEED = 500000;
const char* DANCE_MOVES[] = {
"(>'-')>",
"<('-'<)",
"^('-')^",
"v('-')v",
"(>'-')>",
" (^-^) "
};
int main() {
// unbuffered output for std::cout
std::cout.setf(std::ios::unitbuf);
while (true) {
for(int i = 0; i < 6; ++i) {
std::cout << DANCE_MOVES[i] << '\r';
usleep(MOVE_SPEED);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment