I'm not sure where to direct this question, but on validation my initials.c program i got unexpected errors, for example:

:( outputs "R" for "ROB" \ expected output, but not "RO\n"

:( outputs "RTB" for "Robert thomas Bowden" \ expected output, but not "ROTB\n"

I could to swear that i don't see any ROTB output when enter as input Robert thomas Bowden or RO for ROB and it's returning correct values.

For further test details: https://sandbox.cs50.net/checks/3e80e2e311724752933b5822da44a55a

Also i attach screenshot:

enter image description here

Source code: http://pastebin.com/9sACrPn5

Is it some bug or i'm something doing wrong here? Because of these validation errors i'm a bit afraid to submit this pset.


1 Answer 1


Your code is printing the first two letters. Look at these lines:

    int position;
    if (i == 0 || (position + 1) == i) {
        printf("%c", char2upper(credentials[i]));

Since position starts as 0, the second pass through the for loop (i=1) will satisfy the second part of your test condition so the second letter will print. Maybe if you initialized position to something other than 0?

Also, take a look at toupper() I think you'll find it useful.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thanks for your suggestions. :) You were right, problem was with position variable! But still can't get why in tests it was failing but on my own input with same case not.. Maybe i was already too tired and missed something. Thanks again! Nov 10, 2015 at 11:51

You must log in to answer this question.

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