I got it to work when it's not in a loop. When it's in the loop, it acts pretty crazy then crashes. I tried moving some declarations around but that didn't seem to do much.
Code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char sentence[80];
srand(time(NULL));
char *article[]= {"the", "a", "one", "some", "any"};
char *noun[] = {"boy", "girl", "dog", "town", "car"};
char *verb[] = {"drove", "jumped", "ran", "walked", "skipped"};
char *preposition[]= {"to", "from", "over", "under", "on"};
for(int i = 1; i <21; i++)
{
int articleRand = rand() % 5 ;
int nounRand= rand() % 5 ;
int verbRand = rand() % 5 ;
int prepositionRand= rand() % 5 ;
int noun2 = rand() % 5;
int article2 = rand() % 5;
strcat(sentence, article[articleRand]);
strcat(sentence, " ");
strcat(sentence, noun[nounRand]);
strcat(sentence, " ");
strcat(sentence, verb[verbRand]);
strcat(sentence, " ");
strcat(sentence, preposition[prepositionRand]);
strcat(sentence, " ");
strcat(sentence, article[article2]);
strcat(sentence, " ");
strcat(sentence, noun[noun2]);
strcat(sentence, ".");
cout << sentence << endl;;
}
system("pause");
return 0;
}