-2

I have done some searching, but didn't find the answer
The code:

char b = 'b';
char c = 'c';
char a[5] = "";
a[0] = b, c;

What last line means? The b, c part?

Thank you all

A_S
  • 7
  • 2

1 Answers1

5

That uses the elusive comma operator to cause confusion.

It evaluates b, and result of that is then asssigned to a[0]. After that, c is evaluated but its value thrown away. At least this is the case in C.

The comma has lower precedence than assignment (see this handy table) which is extra confusing.

unwind
  • 391,730
  • 64
  • 469
  • 606