Thread: Insult Generator Help?

  1. #1
    Registered User
    Join Date
    Oct 2011

    Insult Generator Help?

    Hi, my assignment involves writing a program that generates a random insult, made by randomly selecting a word in each of three lists. I know that I have to use pointers and character strings, but I was out of class for the past week and a half with pneumonia, so I'm kind of lost on how to do that and how to get it to print a random one from each of the lists. The final program should read "Thou *word from list 1* *word from list 2* *word from list 3* "

    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <string.h>
    int main()
            srand ( (unsigned)time( 0 ) );
            char * list1[] = {"artless", "bardy", "beslubbering", "bootless",
            "churlish", "cockered", "clouted", "craven", "currish", "dankish",
            "dissembling", "droning", "errant", "fawning", "fobbing", "froward",
            "frothy", "gleeking"};
            char * list2[] = {"base-court", "bat-fowling", "beef-witted",
            "beetle-headed", "boil-brained", "clapper-clawed", "clay-brained",
            "common-kissing", "crook-pated", "dismal-greaming", "dizzy-eyed",
            "doghearted", "earth-vexing", "dread-bolted", "elf-skinned",
            "fat-kidneyed", "fen-sucked", "flap-mouthed"};
            char * list3[] = {"apple-john", "baggage", "barnacle", "bladder",
            "boar-pig", "bugbear", "bum-bailey", "canker-blossom", "clack-dish",
            "clotpole", "coxcomb", "codpiece", "death-token", "dewberry",
            "flap-dragon", "flax-wench", "flirt-gill", "foot-licker", "measle"};
            printf("Thou %s, %s, %s\n", list1, list2, list3);

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    printf("Thou %s, %s, %s\n", list1[0], list2[8], list3[5]);

    This will print the 1st, 7th and 4th insult from the list. Now you need three variables to replace the three constant numbers and you need to assign random numbers to those variables before printing.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Oct 2011
    Awesome, got it. Thanks so much!

  4. #4
    Registered User
    Join Date
    Oct 2011
    One more quick question. I have to make it so at the end it asks if the user would like to try again, and then loop the program if they do. Right now I'm using a goto function, but I know that's shunned upon, but for whatever reason, I can't get it to work with an if or while loop.

    This is what I have now
            printf("Have you had enough? (y/n)\n");
            scanf("%c", &ans);
            if (ans == 'n' || ans == 'N')
                    goto rerun;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doc generator
    By blanc-de-poulet in forum C Programming
    Replies: 2
    Last Post: 05-13-2005, 02:35 PM
  2. NYTimes interview with Triumph, the insult comic dog
    By axon in forum A Brief History of
    Replies: 0
    Last Post: 02-14-2005, 05:57 PM
  3. Name Generator
    By MMD_Lynx in forum C Programming
    Replies: 16
    Last Post: 01-08-2005, 01:11 PM
  4. .SFV Generator
    By Zewu in forum A Brief History of
    Replies: 2
    Last Post: 07-15-2004, 12:00 PM
  5. Name Generator
    By drdroid in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2002, 12:42 PM