Pelles C forum

C language => Beginner questions => Topic started by: Tapasweni Pathak on January 01, 2014, 12:32:16 PM

Title: Comma as a sequence point in for loop
Post by: 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?
or is it undefined?

++i, numbers[i] = i;

comma here, is acting as an operator or separator, inside the for loop?
Title: Re: Comma as a sequence point in for loop
Post by: frankie on January 01, 2014, 06:50:55 PM
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.  (http://en.wikipedia.org/wiki/Comma_operator)