Skip to content

Instantly share code, notes, and snippets.

@john302
Created November 1, 2018 00:15
Show Gist options
  • Save john302/de833db0e95e1edce084dac86dedf9fb to your computer and use it in GitHub Desktop.
Save john302/de833db0e95e1edce084dac86dedf9fb to your computer and use it in GitHub Desktop.
Print random information with a simple C program.
/* Emacs style mode select: -*- linux-c -*-
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/********************************************************************
* Description: Random Link CGI Script.
* Author: Saruman <>
* Created at: Sun Sep 11 02:05:26 EST 2005
* Computer: Battlestar
* System: Linux 2.6.10 on i686
*
* Copyright (c) 2005 Saruman All rights reserved.
*
********************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
const char *links[] = {
"http://s2.enemy.org",
"http://www.planetps2. com",
"http://www.redhat.com",
"http://www.atomicmpc.com.au",
"http://www.slashdot.org",
"http://www.debian.org"
};
void html()
{
printf("Content-type: text/html\n\n");
printf("<html>\n");
}
void html2()
{
printf("</body></html>\n");
}
int main(void)
{
int i;
html();
printf("<h1>C++ Random Link Program.</h1>");
printf("<p>And now for a random image.</p>\n");
srand(time(NULL));
i = rand() % 6;
printf("<p><em>\x6fRandom Link. %s</em></p>\n", links[i]);
/* Selecting a random image. */
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
printf("<img src='../maps/00%i.png' width='320' height='200' \
/>\n", i);
}
html2();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment