Skip to content

Instantly share code, notes, and snippets.

@mlc
Created December 1, 2012 23:54
Show Gist options
  • Save mlc/4186000 to your computer and use it in GitHub Desktop.
Save mlc/4186000 to your computer and use it in GitHub Desktop.
port of 10 PRINT to C
/*
* port of
* 10 PRINT CHR$(205.5+RND(1)); : GOTO 10
* to modern-ish C
*/
#include <locale.h>
#include <wchar.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#define US_IN_NS 1000
#define MS_IN_NS (1000*US_IN_NS)
int main(int argc, char** argv) {
unsigned int seed = time(NULL);
struct timespec ns;
ns.tv_sec = 0;
ns.tv_nsec = 5 * MS_IN_NS;
setlocale(LC_ALL, "");
while(1) {
putwchar(0x2571 + (rand_r(&seed) & 1));
fflush(stdout);
nanosleep(&ns, NULL);
}
return 0;
}
╲╲╱╲╲╲╲╲╲╲╱╱╲╱╱╱╱╲╲╱╱╱╲╲╲╲╲╲╱╱╱╱╱╲╱╱╱╱╱╲╱╲╲╲╲╱╲╲╲╲╲╲╲╱╲╲╲╲╲╲╲╲╲╲╲╲╲╱╱╱╱╲╱╲╲╲╱╱╱╱
╱╱╲╲╲╱╱╲╲╱╲╲╲╲╱╲╲╲╲╱╲╱╱╲╱╱╱╱╲╲╲╱╲╱╱╱╱╲╲╲╲╱╱╱╲╲╲╱╲╱╲╱╲╲╱╱╲╲╲╱╱╱╲╲╲╱╱╱╱╱╱╱╱╱╱╲╲╲╱╱
╲╲╱╲╲╲╱╱╱╱╲╱╲╱╱╲╲╱╲╱╲╱╲╱╱╲╱╱╱╲╱╲╱╱╱╲╱╲╱╲╲╱╱╱╲╱╱╲╲╲╱╱╲╱╲╲╲╲╱╱╲╱╱╱╲╱╲╲╱╲╲╲╱╱╱╲╲╲╱╱
╱╱╱╱╱╲╲╲╱╱╱╲╱╲╱╱╱╲╲╲╱╲╲╱╲╲╲╱╱╲╱╱╲╲╱╱╲╲╱╱╱╲╲╲╱╱╱╲╱╲╲╱╲╱╱╱╱╱╱╱╱╲╱╱╱╱╲╱╲╲╱╱╲╱╲╱╲╲╱╱
╲╲╲╲╲╲╱╲╲╱╱╱╱╱╱╱╱╱╱╱╲╲╲╲╱╱╱╱╱╲╲╲╱╱╲╱╲╱╲╱╲╱╱╱╲╲╲╱╲╲╱╱╲╱╲╱╱╲╲╱╱╱╱╱╱╲╱╱╲╲╱╱╲╲╲╲╲╲╱╱
╱╱╱╲╱╱╱╲╲╲╲╱╲╲╱╲╲╲╱╲╱╲╱╲╱╱╱╱╲╲╲╱╱╱╲╲╱╲╲╲╲╲╲╲╱╱╱╱╱╱╱╱╲╱╱╱╱╲╱╲╲╱╱╱╲╲╲╲╱╲╲╱╲╱╲╱╱╲╲╲
╱╱╱╲╱╲╱╲╱╲╱╲╱╱╲╲╱╲╱╲╲╲╲╲╱╱╲╲╲╲╱╲╲╱╱╲╱╱╱╱╲╲╲╱╱╱╲╲╱╱╱╱╲╲╱╱╲╲╲╲╱╲╱╱╱╱╲╲╱╲╲╲╲╱╲╱╱╲╲╲
╲╱╱╱╲╲╱╱╲╱╲╲╱╲╱╲╱╲╲╱╱╱╲╱╱╲╱╲╲╱╲╱╲╱╲╱╲╱╲╲╱╲╱╱╲╲╱╲╲╱╲╲╱╲╱╱╲╲╱╲╲╱╲╱╲╱╲╱╱╱╲╱╱╲╱╲╱╱╱╱
╲╱╲╱╲╲╲╲╲╲╱╲╲╱╲╲╱╲╱╲╲╱╲╲╱╲╲╱╲╱╱╱╲╱╲╱╱╲╱╱╱╲╲╲╱╲╲╲╲╲╱╲╱╲╱╲╲╱╲╱╲╱╲╱╱╱╱╲╱╲╱╱╲╱╲╱╲╲╱╱
╲╱╱╲╱╲╱╱╲╲╲╲╲╲╱╲╲╲╱╱╱╱╲╲╲╲╱╲╱╲╲╲╱╲╱╲╱╱╲╱╲╲╲╲╲╱╲╲╱╲╲╲╱╱╲╲╱╲╱╱╲╲╱╱╱╲╱╲╱╲╱╲╱╲╲╱╱╱╱╲
╱╲╱╲╱╲╲╱╲╲╱╲╲╱╲╱╱╱╲╲╲╱╲╲╱╲╲╱╱╲╲╲╱╲╱╲╲╱╲╱╲╱╲╱╲╱╲╲╲╱╱╲╱╱╱╲╱╱╲╲╱╱╲╲╱╱╱╲╱╱╱╱╱╲╱╲╲╱╱╱
╲╱╲╲╲╱╲╱╲╲╱╲╲╲╱╲╲╲╲╱╲╲╱╲╲╲╱╲╱╲╱╲╲╱╱╲╱╲╲╱╲╲╲╲╲╲╱╲╲╲╱╱╲╱╲╲╲╲╱╱╲╲╱╲╱╲╱╱╱╱╲╱╲╲╲╲╲╱╱╲
╲╲╱╱╲╲╱╲╱╲╲╲╱╲╱╱╱╱╲╱╱╱╲╱╱╱╱╱╱╲╲╲╲╲╱╱╲╱╲╲╲╱╱╱╱╲╲╲╱╱╲╲╲╱╲╱╱╲╱╲╱╲╲╱╱╱╲╲╱╱╱╲╱╲╱╱╱╱╲╱
╲╱╱╲╱╲╲╱╲╱╱╱╱╲╱╱╲╲╲╱╲╱╲╲╱╲╲╲╱╱╱╱╲╲╲╱╲╲╱╱╱╱╱╲╲╱╲╱╱╲╱╱╱╲╲╱╱╲╲╱╲╱╲╲╱╱╲╱╱╲╱╱╱╲╱╱╲╱╱╲
╱╲╱╱╱╱╲╱╱╱╲╲╱╲╱╲╲╲╲╲╱╲╲╲╱╲╲╲╲╱╲╲╱╱╱╱╲╲╲╱╲╲╲╲╲╱╲╱╲╲╱╲╱╲╲╲╱╲╲╲╲╲╱╱╲╲╱╲╱╱╲╱╲╱╲╱╱╱╲╱
╲╲╲╲╱╲╱╲╱╱╲╱╱╱╱╲╲╲╱╲╱╱╱╲╲╱╱╲╱╲╲╲╱╱╲╲╲╲╲╱╱╲╲╱╲╱╱╲╱╲╲╱╲╲╱╲╱╱╱╱╱╱╱╲╱╲╲╲╱╱╲╱╲╲╲╲╱╱╱╱
╲╲╱╲╱╱╲╱╱╲╲╲╲╲╲╲╲╲╱╲╲╲╲╲╱╱╱╲╱╲╱╲╲╱╲╲╲╱╱╱╱╲╱╱╲╲╲╲╱╲╱╲╲╲╲╱╱╱╱╱╲╱╱╱╲╲╱╲╲╱╲╲╲╱╱╲╲╱╲╲
╱╱╲╲╱╱╲╱╱╲╲╱╱╱╲╲╲╲╱╱╲╲╱╱╲╱╲╱╱╲╱╲╲╲╱╲╲╲╲╲╱╱╱╲╱╲╲╱╲╲╲╱╱╲╱╲╲╲╲╲╱╲╲╲╱╱╱╱╲╲╱╱╱╱╱╲╲╱╱╲
╲╱╲╲╱╲╲╲╱╱╱╲╱╱╱╲╱╱╱╱╱╲╲╲╱╱╲╲╱╱╲╱╲╲╱╱╲╲╲╱╱╲╱╱╱╲╲╲╲╱╱╱╲╱╱╱╱╲╲╲╱╱╲╲╲╱╲╲╲╱╲╲╲╲╱╱╲╱╱╲
╱╲╱╱╲╲╲╲╲╲╱╲╲╲╱╲╱╱╲╲╱╱╱╱╱╲╲╲╲╱╱╱╱╱╱╲╱╲╱╱╱╱╱╲╱╱╱╱╲╲╱╲╱╱╱╱╱╱╲╲╲╲╲╱╲╱╱╲╱╱╱╲╲╲╱╲╱╱╱╲
╲╲╱╱╱╲╲╲╱╲╱╱╱╱╲╲╱╱╱╲╲╲╱╱╲╱╲╲╲╱╱╲╱╲╲╲╲╲╱╱╲╲╲╱╱╱╱╲╲╱╱╲╲╲╱╲╲╱╲╲╱╱╱╱╲╱╱╱╱╲╲╲╲╲╱╲╱╱╱╱
╲╲╲╱╲╲╱╲╲╱╱╱╲╲╱╱╱╱╱╱╲╲╱╲╱╲╲╱╲╲╱╱╲╱╱╱╱╱╱╱╱╲╱╱╲╲╲╱╲╲╲╲╱╱╲╱╲╱╲╲╱╲╲╲╲╱╲╱╲╲╱╲╱╱╱╱╲╱╱╲
╱╱╲╲╱╱╲╲╲╱╱╲╲╲╱╱╱╱╱╱╲╲╲╲╱╱╲╱╲╲╲╲╱╲╱╱╱╱╲╲╱╲╱╲╱╲╲╱╱╲╱╱╱╱╱╲╲╱╲╲╱╲╱╲╲╲╲╱╲╲╱╲╲╱╱╲╱╱╱╲
╱╱╲╱╱╲╲╱╲╱╱╱╱╱╲╲╲╱╱╲╲╱╲╱╲╱╲╲╱╱╱╱╲╲╲╱╲╱╱╱╲╲╱╲╱╲╲╲╲╱╲╲╱╱╲╱╱╲╲╱╱╱╲╲╲╲╲╲╱╱╱╱╱╱╱╲╲╱╱╲
╱╱╲╱╱╲╲╱╲╲╱╲╲╲╲╱╲╱╲╱╱╲╲╲╱╱╱╱╲╱╱╲╱╲╱╱╲╱╱╱╲╲╱╱╱╲╲╲╱╲╲╲╱╲╲╲╱╱╱╱╲╲╱╲╱╲╲╱╲╲╲╱╱╲╲╱╲╲╲╲
╱╱╱╲╱╱╲╲╱╲╲╱╱╱╲╲╲╱╱╱╱╲╱╱╱╱╱╲╲╲╱╱╱╱╱╱╱╲╲╲╲╱╲╱╱╱╲╲╲╲╲╱╱╱╲╱╱╲╱╲╲╱╱╲╲╱╱╱╲╱╱╲╱╲╲╱╱╲╱╱
╲╱╲╱╲╲╲╱╲╲╲╱╲╱╲╱╲╱╱╲╱╲╱╱╲╲╲╱╲╱╲╱╲╱╱╱╲╲╱╱╱╲╲╱╱╱╱╱╲╲╱╲╱╲╲╱╲╱╲╱╲╲╱╲╱╱╲╱╱╲╱╱╱╱╲╲╲╲╲╲
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment