My assignment is to fix the code. I have my edited code below and the original code below that. I figure I still have a few errors in here. My error checking doesnt seem to w
The issues with the original program are:
((c<'0') || (c>'9'))
. exit
function you need to include "stdlib.h".main
function to understand what is get_number
, you need to either move the function to be before the main
function, or you can use a forward declaration.=
) has lower precedence than the inequality operator (!=
), so you need to use parenthesis, like: ((c = getchar()) != '\n')
You have actually created several more issues, so I wouldn't rely on your code.
In any case, in general - it is advised you study how to use a debugger. Once your code is compiling (and for that you'll need to get accustomed to the compilation error messages), you need to start debugging your code. I suggest you take some time to learn how to set breakpoints, set watches, and go step by step into your code. That skill is absolutely essential for a good developer.