0

Here's the body of my code:

int main(void)
{

    // Ask user to enter name and reject just hitting Enter
    do 
    {
        name = GetString();
    }
    while (name == NULL);

    // get the first letter of the first name and put it into the first letter of initials
    n = 1;
    initials[n] = name[0];    

    // find the first letter of the other parts of the name
    for (i = 0;i < strlen(name);i++)
    {
        // if you find a space, take the next character
        if (name[i] == 32)
        {
            i++;
            n++;
            initials[n] = name[i];
        }
    }
    // print each initial
    for (p = 0;p <= (n + 1);p++)
    {

        // make the initial a capitol letter if it isn't already
        if (initials[p] > 90)
        {
            initials[p] = initials[p] - 32;    
        }

        printf("%c",initials[p]);
    }
    printf("\n");
    return 0;
}

I run check 50 and it comes up with this, for example:

:( outputs "R" for "ROB"
\ expected output, but not "\u0000R\u0000\n"
:( outputs "RTB" for "Robert thomas Bowden"
\ expected output, but not "\u0000RTB\u0000\n"

What are those \u0000 characters, and where are they coming from? I can't see what I've done wrong, here.

1
  • I did a search for \u0000 and it says it's the "NULL" character. I don't see where I'm adding it in the code? Nov 28 '15 at 16:19
0

Nevermind, I see what I did wrong. I started my "initials[]" string on the "1th" character, instead of the "0th"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .