For initials.c I've coded so I have the correct output of the initials in capital letters but when I run check50 it says it is incorrect.
I've changed my code multiple times with the \n within the loop and outside at the end etc and still get error messages.
Anyone know what I am doing wrong?
Here's the error:
:) initials.c exists
:) initials.c compiles
:( outputs "MB" for "Milo Banana"
\ expected output, but not "B\n"
:( outputs "MB" for "milo banana"
\ expected output, but not "B\n"
:( outputs "RTB" for "Robert Thomas Bowden"
\ expected output, but not "TB\n"
:( outputs "R" for "ROB"
\ expected output, but not "\n"
:( outputs "RTB" for "Robert thomas Bowden"
\ expected output, but not "TB\n"
Here's my code:
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
string name=GetString ();
for (int i = 0; i < strlen(name); i++)
{
if (name[i] == ' ' && name[i+1] != '\0')
printf("%c", toupper(name[i+1]));
}
printf("\n");
}