I found this expression in a C program and I didn't get it :
struct stack_rec *ss;
ss=(struct stack_rec *)EMalloc(sizeof(struct stack_rec));
if (ss) {
int res;
res = (ss->elem = * i , 1); // what does this mean ????
if (res <= 0)
return res;
if (*s == 0) {
ss->next = 0;
} else {
ss->next = *s;
}
*s = ss;
return 2;
}
return 0;
What does res = (ss->elem = * i , 1);
mean? Is it a boolean expression? I've tried it with a 0 instead of 1 and it always returns the value of the second parameter! Can anyone explain this expression, please?
Looks broken. It's a use of the comma operator, which simply evaluates to the value of the final expression, i.e. 1
.
Therefore, since that code is equivalent to:
ss->elem = *i;
res = 1;
The subsequent testing of res
seem pointless, and thus broken.