/* ********************************************************************** * Fortun.C - For

---
Master Index Current Directory Index Go to SkepticTank Go to Human Rights activist Keith Henson Go to Scientology cult

Skeptic Tank!

/* ********************************************************************** * Fortun.C - Formatted so that it is readable by humans by Fredric * * Rice, The Skeptic Tank, 1:102/890.0. * * * ********************************************************************** */ #include #include #include static char *w[] = { "evolution","the","theory","that","evolutionists","of", "Evolution","scientific","is","and","intermediates","evidence", "to","for","because","not","would","from","religion","The","you", "their","believe","Evolutionism","evolutionary","belief","are", "proven","used","this","be","everything","themselves","There", "anything","creation","can","promote","who","This","God", "Creator","science","humans","merely","people","choose","effort", "how","an","which","by","has","these","ideas","world","as","down", "in","on","does","just","pure","it","know","then","more","when", "so","with","much","good","no","we","was","all","he","at","if", "am","It","did","His","one","non","or","do","If" } ; /* ********************************************************************** * The main entry point. * * * ********************************************************************** */ int main(int argc, char *argv[]) { int available, index, requested, *order; unsigned char length, printed; FILE *fin; /* * Initialize things */ requested = 1; printed = 0; /* * Examine the commnand-line arguments for the number of quotes to offer */ if (argc > 1) { requested = atoi(argv[1]); } /* * Seed the random number generator */ srand((unsigned)time(NULL) / 2); /* * Open-up the data file */ if ((fin = fopen("FORTUN.CMP","rb")) == (FILE *)NULL) { (void)printf("I can't open file: FORTUN.CMP!\n"); fcloseall(); exit(10); } /* * Get the first number from the data file. It tells us how many * items are in the file. */ (void)fscanf(fin, "%d\n", &available); /* * Allocate so many integers for the number of entries */ order = (int *)malloc(sizeof(int) * available); /* * If the number requested is greater than that available, set * the number requested to the maximum available. */ if (requested >= available) { requested = available - 1; } /* * Initialize the order array to zero */ for (index = 0; index < available; ++index) { order[index] = 0; } /* * Randomize the quote order */ for (index = 0; index < requested; ++index) { while((++order[rand() % available]) > 1); } index = 0; /* * Do it all */ do { length = getc(fin); /* Get the length of the text */ if (order[index] && !feof(fin)) { if (length < 128) { putchar(length); printed = 1; } else { (void)printf("%s", w[length - 128]); printed = 1; } } if (length == '\n') { ++index; if (printed) { (void)printf("\n"); printed = 0; } } } while(! feof(fin)); /* * Close up shop and exit */ (void)fclose(fin); return(0); }

---

E-Mail Fredric L. Rice / The Skeptic Tank