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");
}
}