Comma as a sequence point in for loop

Started by Tapasweni Pathak, January 01, 2014, 12:32:16 PM

Previous topic - Next topic

Tapasweni Pathak

I have a line of code,

int numbers[n];
for( i = 0; i < n; ++i, numbers [i] = i );




is , a sequence point here?
or is it undefined?

++i, numbers[i] = i;

comma here, is acting as an operator or separator, inside the for loop?

frankie

Quote from: Tapasweni Pathak on January 01, 2014, 12:32:16 PM
I have a line of code,

int numbers[n];
for( i = 0; i < n; ++i, numbers [i] = i );




is , a sequence point here?
What you means for sequence point?
Quote from: Tapasweni Pathak on January 01, 2014, 12:32:16 PM

++i, numbers[i] = i;

comma here, is acting as an operator or separator, inside the for loop?
The comma is acting as 'C' comma operator: separates two statements discarding the result of the first one.
Look here for more details.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide