madlibs makin me mad
ok, so here's a madlibs program i've been working on in which there are character strings for the different types of speech required within the madlib. i used a random number generator since i want it to pick a word at random from the list and insert it into the paragraph. compiled it in visual c++ and it came up with no errors or warnings. when i tried to run the program however, it crashed visual c++. please help if you know what i've done wrong here >_<
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
void main ()
{
char *noun [5] = {"toilet", "pluto", "potion", "tissue", "cheese"};
char *adjective [10] = {"dark", "scary", "gigantic", "smelly", "thick", "slimy",
"bright", "furry", "dank", "dolt"};
char *pluralnoun [6] = {"frogs","penguins", "cows", "computers", "spaceships",
"scaley"};
char *sillyword [2] = {"glorrrrrrp", "slubberdagullion"};
char sentence [3000];
srand(time(NULL));
strcat (sentence, "Those born under the planetary sign of the ");
strcpy (sentence, "noun [rand()% 5]");
strcat (sentence, "possess ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "personalities and are forever searching for new ");
strcat (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "to conquer. This is a more or less ");
strcat (sentence, adjective [rand()% 10]);
strcat (sentence, "month for you because the planet ");
strcat (sentence, sillyword [rand()% 2]);
strcat (sentence, "is directly over your ");
strcat (sentence, noun [rand()% 5]);
strcat (sentence, "and Mercury is influencing your ");
strcat (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "This means you should avoid eating ");
strcat (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "and stay away from anybody with ");
strcat (sentence, adjective [rand()% 10]);
strcat (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "During the coming year you will find conditions getting ");
strcat (sentence, adjective [rand()% 10]);
strcat (sentence, "due to your ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "attitude toward ");
strcpy (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "You are best suited to a/an ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "mate with ");
strcpy (sentence, adjective [rand()% 10]);
strcpy (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "and a/an ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "complexion, which means, of course, that you can look foward to a really ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "life.");
sentence[0]= toupper(sentence[0]);
cout << sentence << endl;
}
cross posted in
coders_haven
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
void main ()
{
char *noun [5] = {"toilet", "pluto", "potion", "tissue", "cheese"};
char *adjective [10] = {"dark", "scary", "gigantic", "smelly", "thick", "slimy",
"bright", "furry", "dank", "dolt"};
char *pluralnoun [6] = {"frogs","penguins", "cows", "computers", "spaceships",
"scaley"};
char *sillyword [2] = {"glorrrrrrp", "slubberdagullion"};
char sentence [3000];
srand(time(NULL));
strcat (sentence, "Those born under the planetary sign of the ");
strcpy (sentence, "noun [rand()% 5]");
strcat (sentence, "possess ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "personalities and are forever searching for new ");
strcat (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "to conquer. This is a more or less ");
strcat (sentence, adjective [rand()% 10]);
strcat (sentence, "month for you because the planet ");
strcat (sentence, sillyword [rand()% 2]);
strcat (sentence, "is directly over your ");
strcat (sentence, noun [rand()% 5]);
strcat (sentence, "and Mercury is influencing your ");
strcat (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "This means you should avoid eating ");
strcat (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "and stay away from anybody with ");
strcat (sentence, adjective [rand()% 10]);
strcat (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "During the coming year you will find conditions getting ");
strcat (sentence, adjective [rand()% 10]);
strcat (sentence, "due to your ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "attitude toward ");
strcpy (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "You are best suited to a/an ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "mate with ");
strcpy (sentence, adjective [rand()% 10]);
strcpy (sentence, pluralnoun [rand()% 6]);
strcat (sentence, "and a/an ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "complexion, which means, of course, that you can look foward to a really ");
strcpy (sentence, adjective [rand()% 10]);
strcat (sentence, "life.");
sentence[0]= toupper(sentence[0]);
cout << sentence << endl;
}
cross posted in
coders_haven