Sure, when you show your code and tell about your problems. Do not forget to push the [CODE] before pasting your code. Happy coding!
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
Start by adding print statements to be sure you are reading the input properly.
Program one step at a time.
First input. Make sure it works.
Next internal representation of the values -- print them. Make sure they are correct.
Next...
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
You also can not assign value of exit at line 16 of edited code of previous poster to value of choice as it is undeclared and uninitialized. It should be compatible integer type variable for the assignment to succeed and to have nonzero value for if test to succeed.
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
You can not yet, because you need tested base forthe function. You must build from beginning. Of course you could use hard wired input for testing the logic for calculations first like I do, others do input routines first only printing it back to confirm you got it in the program correctly. But you should not never add more than one action and then prove that it works correctly.
To stress one more time. If you add statement to your code means thet your other code is proved bug free in basic level (allways some bugs go through the first test cases but whe you notice those you must then go several steps behind in your design process).
You may think it old fashioned way but most times it is usefull to take paper and pencil and draw few schetches and do it first yourself in paper, then explain to computer how to do it.
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
....
buffer[BUFFER_SIZE] = '\0'; /* make sure that the string gets delimited */
...
Useless. By definition fgets() adds the '\0' for you. And it will go intobuffer[BUFFER_SIZE-1] if you fill up the entire buffer.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944