random sentence generator
I've been working on a program over the last few days that asks to create an array of pointers to char called article noun verb and preposition. Basically I need to create random sentences in the format article noun verb preposition article noun verb. The sentences need to start with a capital letter and end with a period.
It sounded pretty simple at first but I seem to be getting lost in how to generate random sentences where the pointers have different rows and collums. There is nothiong similar to this in my book. This s what I have so far, any "pointers" would be greatly appreciated! (bet you haven't heard that on before. :D )
Code:
#include <stdio.h>
#include <string.h>
void sentenceGenerator( char article[], char noun[], char verb[],
char preposition[], char article[], char noun[] );
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", };
int i;
for ( i = 0; i < 6; i++ );
*( artical) = i;
*( noun) = i;
*( verb) = i;
*( preposition) = i;
srand( time( 0 ) );
void sentenceGenerator( artical, noun, verb, preposition, artical, noun )
}
}
void sentenceGenerator( char article[], char noun[], char verb[],
char preposition[], char article[], char noun[] )
{
int i;
for (i = 0; i <20; i++)
{
printf( "%s%s%s%s%s%s.\n", *article, *noun, *verb, *preposition, *article, *noun );
}
}