home *** CD-ROM | disk | FTP | other *** search
- /*
- * MARVIN - Receive a complaint from marvin.
- *
- * If you move the data files for marvin, you need to recompile the
- * program, or nothing will work. To do this, you should be able
- * to simply edit the line "#define MARVIN_PATH..." in marvin.h and then
- * type "make"
- */
-
- #include "marvin.h"
-
- /* You shouldn't need to change anything below here. */
-
- #include <stdio.h>
-
- main()
- {
- FILE *f;
- char snum[20], name[1024], str[256];
- int msg, num;
- long now;
-
- /* get the number of available messages */
- if (f = fopen(MARVIN_PATH "number", "rt"))
- {
- fgets(snum, 20, f);
- fclose(f);
- }
- else
- {
- fprintf(stderr, "marvin: number: Could not open.\n");
- exit(1);
- }
- num = atoi(snum);
-
- time(&now); /* get time value to seed random generator with */
- srand((unsigned) (now % 32767)); /* seed random number generator */
- msg = (int) (rand() % num) + 1; /* get a random message number */
- /* piece together message file name */
- sprintf(snum, "%d", msg);
- strcpy(name, MARVIN_PATH);
- strcat(name, snum);
-
- /* open the message file and print out marvin's complaint */
- if (f = fopen(name, "rt"))
- {
- while (fgets(str, 255, f))
- printf(str);
- fclose(f);
- }
- }
-