I have a program assignment in my C and Unix class that allows the user to enter two numbers in binary seperated by (*,+,-,or /). It then has to produce an answer and loop back to the beginning. It also has to have an option to exit. Can anyone help?
khsoccer 0 Newbie Poster
Recommended Answers
Jump to PostSure, when you show your code and tell about your problems. Do not forget to push the CODE before pasting your code. Happy coding!
Jump to PostStart 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...
Jump to PostYou 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.
Jump to PostYou 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 …
Jump to Post.... buffer[BUFFER_SIZE] = '\0'; /* make sure that the string gets delimited */ ...
Useless. By definition
fgets()
adds the '\0' for you. And it will go into buffer[BUFFER_SIZE-1] if you fill up the entire buffer.
All 17 Replies
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
asitmahato -4 Newbie Poster
khsoccer 0 Newbie Poster
cse.avinash -1 Junior Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
khsoccer 0 Newbie Poster
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
khsoccer 0 Newbie Poster
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
khsoccer 0 Newbie Poster
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.