I need to write a C program that uses random number generation to create sentances. I need to use strcat to form the sentance and it should generate 20 sentances. What i have so far is below. however it is not working. I know that the problem is something with the strcat statement.
Please Help! :confused:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main()
{
const char *article[5] = {"the", "a", "one", "some", "any"};
const char *noun[5] = {"boy", "girl", "dog", "town", "car"};
const char *verb[5] = {"drove", "jumped", "ran", "walked", "skipped"};
const char *preposition[5] = {"to", "from", "over", "under", "on"};
char *sentance[40];
int i = 0;
srand((unsigned)time(NULL));
for( i = 0; i <= 19; i++)
{
strcat(sentance, article[rand()%5], noun[rand()%5], verb[rand()%5], preposition[rand()%5], article[rand()%5], noun[rand()%5]);
printf("\n\n%s %s %s %s %s %s.\n\n", sentance);
}
return 0;
}