So my code in C for the mario steps is correct except that it shows an output when foo is input rather than re-prompting for a valid integer. I did check50 and this was the only error. Where can I read up on how to solve this problem? Or can someone explain the best way to code a failure for when a character is input while running my code? I looked at other questions similar to this but it wasn't the exact same error so I have yet to find a solution. enter image description here


The get_int function from the cs50 library does this for you already, but there is a way to do this without using the cs50 library you can just research about Exceptions, try and catch statements. They are what programmers use deal with input errors like this and they should be fairly simple to understand.

  • I looked it up and tried to implement it but it is not working, nothing prints – Rayray94 May 14 '20 at 21:32
  • Where would I put the exception statement? – Rayray94 May 15 '20 at 1:03
  • I'm sorry for giving out wrong info. I just searched it up and it turns out that C does not support try and catch statements. If you want to finish this problem already just #include <cs50> and use get_int() as it automatically does this for you. But if you want to reinvent the wheel read this question here https://stackoverflow.com/questions/10586003/try-catch-statements-in-c I personally don't quite get the solution but maybe you can get it, sorry again for giving out wrong information, I program in c++ and c++ has try and catch statements sorry. – Ojou Nii May 15 '20 at 13:07
  • It's alright thank you for checking back. I am trying get_int() but still having issues. – Rayray94 May 19 '20 at 21:09
  • Hmmm that's weird get_int should be able to handle non_numeric inputs, it's what I used for this problem and everything worked fine for me. – Ojou Nii May 20 '20 at 5:22

You must log in to answer this question.

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