Skip to content

Instantly share code, notes, and snippets.

@zoeisnowooze
Created October 31, 2022 15:52
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 zoeisnowooze/493e8b720803efb2a0574eadf295ea07 to your computer and use it in GitHub Desktop.
Save zoeisnowooze/493e8b720803efb2a0574eadf295ea07 to your computer and use it in GitHub Desktop.
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
char randascii() {
while (true) {
char r = rand() & 0x7f;
if (r >= 0x20 && r <= 0x7e) {
return r;
}
}
}
int main(int argc, char **argv) {
char last = 0x1f;
int skips = 0;
int line_len = 0;
while (true) {
char c = randascii();
putchar(c);
if (c == last + 1 && skips++ == 10) {
last = c;
if (line_len++ == 15) {
putchar('\n');
line_len = 0;
}
if (c == 0x7e) {
break;
}
skips = 0;
} else {
putchar('\b');
}
usleep(200);
}
putchar('\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment