I am currently taking a class in C online and I have a homework assignment to create a random sentence generator with arrays of specific words. I have the random part working, but I am unsure as to how to capitalize the first letter of the first word in the sentence. I could create a separate array with the capitalized words, but I don't think that conforms to the problem. This is what I have so far, and like I said it works except for the capital letter. I have searched my textbook and online and can't find a way to do this, but I'm pretty sure it is possible. I don't want the answer just pasted here, I want to understand how to do it so an explanation would also be appreciated. Thanks.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
int main(void)
{
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" };
const char *sentence[ 35 ] = {0};
int a=0, b=0, c=0, d=0, e=0, f=0;
int counter=0;
srand(time(NULL));
for (counter=1; counter <= 20; counter++)
{
a = rand() % 5; /*random numbers for each array of words */
b = rand() % 5;
c = rand() % 5;
d = rand() % 5;
e = rand() % 5;
f = rand() % 5;
sentence[1] = article[a];
sentence[2] = noun[b];
sentence[3] = verb[c];
sentence[4] = preposition[d];
sentence[5] = article[e];
sentence[6] = noun[f];
printf("%s %s %s %s %s %s.\n", sentence[1],sentence[2],sentence[3],sentence[4],sentence[5],sentence[6]);
}
printf("\n");
system("PAUSE");
return 0;
}