view raw
Ben Ben - 1 year ago 80 Question

What does j+= (i=j) mean in C++

I have virtually no experience in programming C. But now i have to use a bit of C code in a application.

Translating the code has been succesful so far, but i have encountered this weird (at least for me) statement

j += ( i = j);

both j and i are integers. I have been looking on this forum and Google but found no answer about what it might mean.

A bit further in the C code I have some similar code that looks like

chisq += (temp = y[i] - (aa + bb*x[i]), temp*temp);

all variables except for i are double or an array of doubles.

Please excuse me if I made some grammar or spelling mistakes.

Thanks in advance.


It firsts assigns j to i, and then adds i to j.

Like this:

i = j;
j += i;