> i = j ==1;
This tests if the value of j is equal to 1, if so, then i is assigned
1 (true), if not (most likely since you are grabbing random memory),
then it is assigned 0 (false). j should not be assigned in this
statement. It may be a fluke that it is 0 (or your compiler init
unassigned vars?)
> i = j = 1;
In this situation, i and j are being assigned the value 1.
Some people prefer to say "gets" with = and "is equal to" with ==, to
distinguish between assignment and equality tests, respectively.
This logic is also valid in C.
#include <stdio.h>
int main(){
int i, j, k, l;
i = j == 1;
k = l = 1;
printf("i:%d j:%d, k:%d l:%d\n", i, j, k, l);
return 0;
}
produces:
i:0 j:-1078123064 k:1 l:1
on my computer.
Jim
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|