/* Change this to the directory where your GIF images are kept. Make sure a final slash appears. This is NOT a file system path; it is the URL on your server where the images can be found. */ #define IMAGE_DIR_URL "/CHANGE/THIS/URL/images/" #include #include /* Included so we can get the current time for use as a random number "seed" to get a unique series of random numbers */ #include int main(int argc, char *argv[]) { time_t now; char imagePath[256]; int choice; time(&now); srand((unsigned int)now); printf("Content-type: text/html\n\n"); printf("\n"); printf("\n"); printf("Random Inline Images Demonstration\n"); printf("\n"); printf("\n"); printf("

Random Inline Images Demonstration

\n"); printf("

This page contains one of four possible inline images,\n"); printf("selected at random.\n"); /* Choose a random winner from among the four images */ choice = rand() % 4; /* Format the URL. */ sprintf(imagePath, "%s/image%d.gif", IMAGE_DIR_URL, choice); /* Now output the tag. */ printf("\n", imagePath); printf("\n"); printf("\n"); return 0; }