[LCP]which one first?
Mike & Penny Novack
stepbystepfarm at shaysnet.com
Tue Mar 12 01:07:07 UTC 2002
> here is a following code have a look,
>
> for(i = 0; buf[i] != ' ' && buf[i] != '\0'; value[i] = buf[i], i++);
>
> which statement will execute first
> value[i] = buf[i] or
> i++
> please give reasons.
>
Mehul,
1) value[i] = buf[i] will be done first
2) It's a "comma expression". There are two (very different) uses of the
symbol ',' in C. When it is used between the parameters of a function
call it does NOT guaranteee anything about order of execution. But when
used between terms of an expression.....
{expr1 , expr2, ........, exprn}
then you are guaranteed that:
a) they will execute in that order
b) the value of the entire thing will be the value of exprn
Mike
More information about the linuxCprogramming
mailing list