Last active
December 20, 2015 15:59
-
-
Save mgold/6158168 to your computer and use it in GitHub Desktop.
Translates octal digits into ASCII art, with the brightness correlated to the magnitude of the digit. The input may be either ASCII octal digits or machine octal. Try it on random data, or the compiled executable of the program (and vary your terminal width). A hexidecimal version is also available.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* octBright.c - visualize octal data with brightness | |
* Max Goldstein | |
* | |
* example usage: | |
* $ od -o < /dev/random | sed 's/^[0-9]* +//' | tr -d ' ' | ./octBright | |
*/ | |
#include <stdio.h> | |
int main(){ | |
while(1){ | |
int c = getchar(); | |
if (c == EOF){ | |
break; | |
} | |
if (c >= '0' && c <= '7'){ | |
c -= '0'; | |
} | |
if (c >= 0 && c <= 7){ | |
putchar(".-~:;#$@"[c]); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment