goo goo - 1 year ago 106
C Question

Back-to-back assignments in C

I came across this code today:

for (i = 0; i < level; i++) {
a[i] = b[i] = c[i] = 0;
}


What is the meaning of the code located inside the for loop?

Answer Source
 a[i] = b[i] = c[i] = 0;

is parsed as:

 a[i] = (b[i] = (c[i] = 0));

and is equivalent to:

 a[i] = 0;
 b[i] = 0;
 c[i] = 0;