Here's my main
char* name = GetString();
if(name != NULL)
{
for(int i = 0, j = strlen(name); i < j; i++)
{
if(!isalpha(name[i-1]) && isalpha(name[i]))
printf("%c", toupper(name[i]));
}
printf("\n");
}
The program works pretty good; it passed all the (check50) tests.
But I'm worried about a possible bug and that is when i = 0
, could the value stored in name[-1]
be an alpha character?
Note: the GetString()
function returns a string entered by the user.