this is my first time on the forum, I am trying initials.c on pset2, I have managed to do the code which gets the first letter of the word and capitalizes it. My problem is when the user enters just a first name or a first and second. I have tried multiple methods all with little success including a do while secondn[0] = \0 and a isblank(). Can you guys possibly point me in the right direction?
int main(void)
{
char firstn[15], secondn[15], thirdn[15];
//Declaring: firstname, middle name and last name, each of can have a maximum of 14 characters accounting for the null zero
scanf("%s %s %s" , firstn , secondn, thirdn); //Reads the values entered and implements them into the respective character strings
if (secondn[0] == '\0') // Hopefully sees if secondn has a \0 in it, if it does only print firstn
{
printf("%c\n" , toupper(firstn[0]));
}
if (thirdn[0] == '\0') // Hopefully sees if thirdn has a \0 in it, if it does only print firstn and secondn
{
printf("%c%c\n" , toupper(firstn[0]) , toupper(secondn[0]));
}
//do
//{
// printf("secondname is empty");
// }while (secondn[0] == '\0');
//if (char isblank(char secondn));
//{
// printf("second n is empty");
//}
printf("%c%c%c\n" , toupper(firstn[0]) , toupper(secondn[0]) , toupper(thirdn[0])); //Takes character zero of each entity, character zero is the first character as this is zero indexed.
}