puting an element from many areas inside one big array?
I made this random sentance generating program it generates 20 sentences and it's is currently working like it's supposed to. I need to change comething though. Instead of printing out the array elements individually, I am supposed to concatenate them into one array named that looks like thisI don't know how to go about doing that though. I need to concatenante all of the elements in one array with spaces in between the words, a capital letter at the begining and a period at the end. I tried playing around with strcat, but didn't have much luck.
Code:
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
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;
cout << article[articleRand] << " " << noun[nounRand] << " "
<< verb[verbRand] << " " << preposition[prepositionRand]
<< " " << article[article2] << " " << noun[noun2] << "." << endl;
}
system("pause");
return 0;
}
Any help would be greately appreciated!