Return to Snippet

Revision: 21295
at December 9, 2009 07:58 by Zufolek


Initial Code
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int randchar(){
 if(rand()<RAND_MAX/8)return ' ';
 return 'A'+rand()%26;
}


int main(){
 long int z=32768;//# of bytes to output
 srand(time(0));
 FILE*f=fopen("monkey.txt","wt");
 while(z--&&!ferror(f))
  putc(randchar(),f);
 fclose(f);
 system("notepad monkey.txt");//opens file w/ notepad
 return 0;
}

Initial URL


Initial Description
"The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type a given text, such as the complete works of William Shakespeare."

http://en.wikipedia.org/wiki/Infinite_monkey_theorem

Initial Title
Monkey Typewriter

Initial Tags


Initial Language
C