0

When I run the Mario.c program I created my output seems to be exactly the same as what I get when I run ~cs50/pset1/mario, but when I use check50 for the problem set (exact input below) I get a bunch of statements indicating " \ expected output, not an exit code of 0."

I have looked at several other questions related to the check for mario, but haven't been able to figure out where I am going wrong. I was able to make a few minor tweaks moving in the right direction (I had an extra space before my hashes and fixed that).

Below is the the response to my check:

jharvard@appliance (~/Dropbox/pset1): check50 2014/x/pset1/mario mario.c

:) mario.c exists

:) mario.c compiles

:( rejects a height of -1
   \ expected output, not an exit code of 0

:( handles a height of 0 correctly
   \ expected output, not an exit code of 0

:( handles a height of 1 correctly
   \ expected output, not an exit code of 0

:( handles a height of 2 correctly
   \ expected output, not an exit code of 0

:( handles a height of 23 correctly
   \ expected output, not an exit code of 0

:( rejects a height of 24
   \ expected output, not an exit code of 0

:( rejects a non-numeric height of "foo"
   \ expected output, not an exit code of 0

:( rejects a non-numeric height of ""
   \ expected output, not an exit code of 0

https://sandbox.cs50.net/checks/7dd64bc2a7c94b8ebaea7ad14ec1df8a

I was going to include some of my outputs, but when I past them from vmware into this program, they unfortunately don't look the same. My outputs don't have extra spaces or lines, the pyramids are the correct height, and the program reprompts with "Height" or "Retry" for entries which are not integers between 0-23.

Any suggestions or tips are greatly appreciated.

1

I finally solved the above problem and wanted to share my solution in case it helps anyone else.

I was using a while loop to re-prompt for input for heights that were not between 0-23 (inclusive). For some reason this was causing check50 to view the output as an exit code and overlook the spaces and #s, which were printing just fine when I ran my program.

I changed my while loop to a do while loop and check50 came back all green.

I don't understand why this is the case and would appreciate anyone who could explain why it matters if the pyramid prints correctly. As an absolute beginner, I suspect there might be something important here that I am overlooking.

Credit goes to the Reddit post below, which pointed me in the right direction:

"Pset1 check50 error: Mario seems to work correctly" by junecar

"[–]junecar[S] 2 points 9 months ago Finally, all green smiles on mario! Shout out to delipity; you were very helpful, thank you! This is my layman's explanation of the problem/solution: It ended up being an initial while loop that stopped the program before it started when running through check50; hence the exit code 0 instead of an output."

| improve this answer | |
  • A do while loop will always run the body of the loop at least once, then will test the condition while a while loop tests the condition prior to entering the body the first time. It sounds like the loop was not passing the condition of the loop. Check the value that you initialized the variable to so that it fails the test until you can get the input from the user. – user2913 Nov 3 '14 at 22:00

You must log in to answer this question.

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