0
 h = b = out;

 /* h is the number of code points that have been handled, b is the  */
 /* number of basic code points, and out is the number of ASCII code */
 /* points that have been output.                                    */

I can't figure out whether this line is just a weird way of setting both h and b equal to out OR if it's a boolean expression that sets h equal to true (0?) if b is already equal to out.

phuclv
  • 37,963
  • 15
  • 156
  • 475
Bryan Dunphy
  • 799
  • 1
  • 10
  • 22
  • Neither of the proposed duplicates addresses the part on boolean interpretation. – Yunnosch Nov 09 '20 at 14:48
  • @Yunnosch explaining the correct meaning implies that it doesn't have some different meaning such as a bullean expression – M.M Nov 10 '20 at 02:38

4 Answers4

0

it sets h and b to out. the boolean would be h ? b : out; and means if h true then b else out - so it is setting nothing to h

  • no, this isn't a boolean expression. It'd only be a boolean expression if it's `h = b == out`. The `=` and `==` operators are very different – phuclv Nov 11 '20 at 02:03
  • @phuclv i know that this is not a boolean expression. this is why i wrote "boolean WOULD be"... – quotschmacher Nov 11 '20 at 08:04
  • I've just got your point. The wording makes it easy to think that it means "the equivalent boolean expression would be". And no, that's what the OP is thinking about. He thinks it's something similar to `h = b == out` which is a boolean expression. No one would ever think `h = b = out` as `h ? b : out` – phuclv Nov 11 '20 at 08:12
0

It cannot be boolean, because that would use == instead of =.
So yes, it is a (weird) way of setting two variables, based on the fact that the value of b=out is out.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
0

= is always the assignment operator in C and can't be used for comparing 2 values. To get a "boolean" expression you must use ==. The expression a = b assigns b to a and also returns the assigned value that can be used in another expression. So h = b = out; actually assigns out to both b and h. It's parsed as h = (b = out) because in C the = operator is left associative

Assignment also returns the same value as what was stored in lhs (so that expressions such as a = b = c are possible). The value category of the assignment operator is non-lvalue (so that expressions such as (a=b)=c are invalid).

https://en.cppreference.com/w/c/language/operator_assignment

phuclv
  • 37,963
  • 15
  • 156
  • 475
-2

h = b = out; In C, it means that setting both h and b equal to out. h = ( b = out ); It means boolean expression.

Joseph Lee
  • 13
  • 4