Curses Snow Crash
On my way to work one morning I got the idea for this program. Can it actually be called a program? It's more like a novelty, but so simple to make. Take a look at the excellent cmatrix for a similar, but much more advanced program.
The name is from Neal Stephenson's novel, where I imagine that the "Snow Crash" would look something like the output of this program.
Use it as a screen saver or just for fun, so check out the code:
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <curses.h>
int main(int argc, char *argv[])
{
int x, y, maxy, maxx;
srand(time(NULL));
initscr();
atexit((void *)endwin);
noecho();
timeout(0);
while (1) {
if (getch() != ERR)
return 0; /* Stop on any key press. */
getmaxyx(stdscr, maxy, maxx);
for (y = 0; y < maxy; y++) {
for (x = 0; x < maxx; x++) {
mvaddch(y, x, (rand() % 0x5E) + 0x21); /* 0x21 -> 0x7E */
}
}
refresh();
usleep(40000); /* ~24 frames per second. */
}
return 0;
}
Compiled and run; it will look something like this for each frame, just random characters splattered over the screen:
Here's a statically linked Win32 binary for convenience.