Two Equal Signs in One Line?

The value of the expression (a = b) is the value of b, so you can chain them this way. They are also right-associative, so it all works out.

Essentially

ArcChar = ArcBit = 0;

is (approximately1) the same as

ArcBit = 0;
ArcChar = 0;

since the value of the first assigment is the assigned value, thus 0.

Regarding the types, even though ArcBit is an unsigned char the result of the assignment will get widened to int.


1   It’s not exactly the same, though, as R.. points out in a comment below.

Leave a Comment