Skip to content

Instantly share code, notes, and snippets.

@chessai
Forked from neoeno/sad.c
Created July 31, 2018 03:08
Show Gist options
  • Save chessai/e3d87eb2a11275b4db2fee2707d329ce to your computer and use it in GitHub Desktop.
Save chessai/e3d87eb2a11275b4db2fee2707d329ce to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
const char* RESET = "\x1B[0m";
const char *COLORS[] = { "\x1B[31m", "\x1B[32m", "\x1B[33m", "\x1B[34m", "\x1B[35m", "\x1B[36m" };
int main() {
srand(time(NULL));
for(;;) {
int colorIdx = rand() % 6;
printf("%s:(%s", COLORS[colorIdx], RESET);
int spacing = rand() % 10;
for(int i = 0; i < spacing; i++) {
printf(" ");
}
fflush(stdout);
usleep(5000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment