2

I have this line:

binary[index] = (tempDecimal % 2) + '0'; 

Could you explain the usefulness of + '0' in this line of code for me?

3
  • While this question is about c and the other one about c++, they indeed are about the same effect. Commented Feb 18, 2019 at 15:27
  • 1
    Yes, this C question should not be marked as a duplicate of the C++ question. While both standards have effectively the same rule, C has the rule because the C standard says so, and C++ has the rule because the C++ standard says so. Commented Feb 18, 2019 at 16:08
  • @EricPostpischil I agree here. While there are places in the C++ standard that defer to a specific C standard (e.g., C11), this is not one of those places. Commented Feb 18, 2019 at 17:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.