Skip to content

Instantly share code, notes, and snippets.

@sergiobuj
Created April 22, 2010 03:35
Show Gist options
  • Save sergiobuj/374781 to your computer and use it in GitHub Desktop.
Save sergiobuj/374781 to your computer and use it in GitHub Desktop.
Simple terminal animation in C
// Sergio Botero
// Status:
#include <cstdio>
#include <string>
int main (){
while( 1 ){
for(int i = 0; i < 25; usleep(30000), printf("%s+%s+%s\r", std::string(i++, ' ').c_str(), std::string( 50-(2*i) , ' ').c_str(), std::string(i, ' ').c_str())) fflush(stdout);
for(int i = 25; i >= 0; usleep(30000), printf("%s+%s+%s\r", std::string(i--, ' ').c_str(), std::string( 50-(2*i) , ' ').c_str(), std::string(i, ' ').c_str())) fflush(stdout);
}
puts("");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment