I have written this code but it only prints the word before space
void LetterCapitalize(char str[])
{
int i;
char res[50];
res[0] = str[0] - 32;
for(i=1;i<=strlen(str);i++)
{
if(str[i] == 32)
{
res[i++] = str[i++] - 32;
}
else
res[i] = str[i];
}
printf("%s",res);
}
int main(void) {
// keep this function call here
LetterCapitalize(gets(stdin));
return 0;
}