If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

C++/C conversion to just C

Below is a program that generates random Addition for Subtraction problems depending on the user's choice. The user is prompted to input an answer and then it keeps your score. If you want to quit you just press zero. This is pretty much my first C program ever, I read the first eight chaps of my C/c++ book and along with supplementary online readings, made it. The thing is, it is suppose to be pure C! I was looking for advice on how to salvage this, please give me your wisdom

Re: C++/C conversion to just C

Originally Posted by chucker

Below is a program that generates random Addition for Subtraction problems depending on the user's choice. The user is prompted to input an answer and then it keeps your score. If you want to quit you just press zero. This is pretty much my first C program ever, I read the first eight chaps of my C/c++ book

What book teaches C/C++?

C and C++ are two separate languages -- either the book teaches C++, or the book teaches C. I know of no book that teaches both languages, and it would be foolhardy (IMO) to have such a book due to the differences in the languages, what is considered legal/illegal syntax, programming paradigms, etc. Such a book, if it exists, would only confuse the programmer trying to learn one language over the other.

Second, since the assignment sounds straightforward, pretend your C++ program doesn't exist. Write it from scratch using 'C'.

Re: C++/C conversion to just C

Originally Posted by chucker

any ideas on how to replace the bool with a C equivalent?

Originally Posted by S_M_A

The normal C-way is just an int. A non-zero value is true and a zero value is false.

C99 introduced 'bool' as a type, along with 'true' and 'false', of course. Although they are just macros under the hood, using them makes the program semantics clearer.
Just make sure to #include <stdbool.h> to use them.

Re: C++/C conversion to just C

Originally Posted by Paul McKenzie

What book teaches C/C++?

C and C++ are two separate languages -- either the book teaches C++, or the book teaches C. I know of no book that teaches both languages, and it would be foolhardy (IMO) to have such a book due to the differences in the languages, what is considered legal/illegal syntax, programming paradigms, etc. Such a book, if it exists, would only confuse the programmer trying to learn one language over the other.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.