0

I could not find the solution for my error on cs50 mario.c/more as my output shows perfectly fine on the terminal but i get check error which I don't understand please help:

:( handles a height of 1 correctly
expected "# #\n", not "##\n" 

Log 
running ./mario... 
sending input 1... 

Expected Output: 
#  #
Actual Output: 
##
:( handles a height of 2 correctly
expected " # #\n## ##\n", not " ##\n###\n" 

Log 
running ./mario... 
sending input 2... 

Expected Output: 
 #  #
##  ##
Actual Output: 
 ##
###
:( handles a height of 23 correctly
expected " ...", not " ..." 

Log 
running ./mario... 
sending input 23... 

:( rejects a height of 24, and then accepts a height of 2
expected " # #\n## ##\n", not " ##\n###\n" 

Log 
running ./mario... 
sending input 24... 
checking that input was rejected... 
sending input 2... 
checking for output " # # ## ## "... 

Expected Output: 
 #  #
##  ##
Actual Output: 
 ##
###

And my code is:

int main(void)
{
    int height, row, leftspace, lefthash, righthash;
    do
    {

    printf("height:");
    height = get_int();

    } while(height < 0 || height > 23);

    for(row = 0; row < height; row++)
    {
        for(leftspace = 0; leftspace<(height-row)-1; leftspace++)
        {
            printf(" ");
        }

        for(lefthash = 0; lefthash < row+1; lefthash++)
        {
        printf("#");
        }

        printf("  ");

        for(righthash = 0; righthash < row+1; righthash++)
        {
        printf("#");
        }

        printf("\n");
    }
}

1 Answer 1

1

Looks like check50 got a different file. Maybe you have forgotten to save, or you are in the wrong directory, one where you stored a solution to mario.less? check50 will always upload mario.c from current directory, it may not be renamed.

4
  • hmm okay i will with making a new file and then check it but i don't understand why my question was being edited was there something wrong the way i asked. P.S I am new in stackexchange
    – NTM
    Oct 20, 2017 at 15:18
  • Click that "edited" link and you can see what I did (I wanted to make your text more readable, no content changes). I selected parts of the text and used the {} button in the editor to add spaces in front of the code lines, as any block of lines starting with 4 spaces each is considered code. Inside a code block, markdown won't be interpreted. You can also have inline code by placing text beteen backticks (` like the accent grave).
    – Blauelf
    Oct 20, 2017 at 15:34
  • So nothing exactly wrong, but you accidentally used markdown. For example, a line starting with a number of # is interpreted as caption. Inside a code block, it no longer is.
    – Blauelf
    Oct 20, 2017 at 15:38
  • ah okay thanks for the explanation and I am better understood about the question posting. Also my cs50 pset mario.c works good. Thanks a lot :) @Blauelf
    – NTM
    Oct 20, 2017 at 15:44

You must log in to answer this question.

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