Skip to main content
2 of 2
added 49 characters in body
Cliff B
  • 69.3k
  • 4
  • 33
  • 56

pset2 initials problem

don't understand why it show error

:) initials.c exists
:) initials.c compiles
:( outputs "MB" for "Milo Banana"
   \ expected prompt for input, not output of "Input you name\n"
:( outputs "MB" for "milo banana"
   \ expected prompt for input, not output of "Input you name\n"
:( outputs "RTB" for "Robert Thomas Bowden"
   \ expected prompt for input, not output of "Input you name\n"
:( outputs "R" for "ROB"
   \ expected prompt for input, not output of "Input you name\n"
:( outputs "RTB" for "Robert thomas Bowden"

code:

string s = GetString();

printf("%c", toupper(s[0]));

for (int i = 1, n = strlen(s); i < n; i++)
{
   if (s[i] == ' ')
   {
     printf("%c", toupper(s[i+1]));
   }
}