I've written a program to produce a random sentence. I'm having trouble converting the first letter of the first word into uppercase. Don't know where to go from here. Can anyone help?
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <ctype.h>
void firstword( char *article[5], char *sentence[6]);
void secondword(char *noun[5], char *sentence[6]);
void thirdword(char *verb[5], char *sentence[6]);
void fourthword( char *preposition[5], char *sentence[6]);
void fifthword( char *article[5], char *sentence[6]);
void sixthword(char *noun[5], char *sentence[6]);
int main()
{
char *article[5]= {"the", "a", "one", "some", "any"};
char *noun[5] = { "boy", "girl", "dog", "town", "car"};
char *verb[5]= {"drove", "jumped", "ran", "walked", "skipped"};
char *preposition [5] ={ "to", "from", "over", "under", "on"};
char *sentence [6];
srand(time(0));
firstword( article,sentence);
secondword(noun, sentence);
thirdword(verb, sentence);
fourthword(preposition, sentence);
fifthword(article, sentence);
sixthword(noun, sentence);
printf("\n");
return 0;
}
void firstword( char *article[5], char *sentence[6])
{
char word;
word = rand() % 5;
sentence[0] = article[word] ;
sentence[0] = toupper(sentence[0]);
printf("%s ", sentence[0]);
}
void secondword(char *noun[5], char *sentence[6])
{
char word;
word = rand() % 5;
sentence[1] = noun[word] ;
printf("%s ", sentence[1]);
}
void thirdword(char *verb[5], char *sentence[6])
{
char word;
word = rand() % 5;
sentence[2] = verb[word] ;
printf("%s ", sentence[2]);
}
void fourthword( char *preposition[5], char *sentence[6])
{
char word;
word = rand() % 5;
sentence[3] = preposition[word] ;
printf("%s ", sentence[3]);
}
void fifthword( char *article[5], char *sentence[6])
{
char word;
word = rand() % 5;
sentence[4] = article[word] ;
printf("%s ", sentence[4]);
}
void sixthword(char *noun[5], char *sentence[6])
{
char word;
word = rand() % 5;
sentence[5] = noun[word] ;
printf("%s.", sentence[5]);
}