0

So my code printed fine when I used printf and scanf together but when I changed it to the get_int command it no longer prints anything. How do I use get_int and still print my code? The purpose of switching to get_int was so that my code would re-prompt when any characters were entered. Other recommendations like using exceptions to avoid characters was too confusing and since I am new to coding I can't figure out how to implement it. enter image description here

0

You keep saying "print my 'code' ". Are you trying to print out the data that you just took in with get_int? The get_int() function doesn't print out what was taken in (You can actually read the source code, if you find it - use google.)

Instead, you'd need to add a printf line after the get_int to reprint the input value if you want, or for diagnostic and testing purposes, although that would cause check50 to fail.

| improve this answer | |
  • I really mean how do I get my code to run and show the steps. It's hard for me to know how to form my questions since I have no prior coding knowledge. Aww man it's a check50 fail that made me change my code in the first place. Do I have to ask another question to find out how to do that without failing check50? – Rayray94 May 14 at 23:03
  • What you really want to do is to learn how to use debug50. I don't know if the instructions have been offered in the course at the point you're at yet. But you can go ahead and play with it anyways. Set a breakpoint in your code (click on a line number in the IDE and a red dot will appear.) Then, enter this on a command line debug50 ./mario And then, start playing with it. Add and remove breakpoints, use the controls in the right side window at the top to step through code, look at variables, etc. Remember that the highlighted line has yet to be executed. – Cliff B May 14 at 23:13
  • Alright I'll look it up. – Rayray94 May 14 at 23:37

You must log in to answer this question.

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