hi all..
I recently came through this like a statement in AVR c project ,and I was wondering whether it is an augmented assignment or a comparison..
a = ( b() != c );
a = ( b != c );
Any help is much appreciated..
thanks.
BR
Kanishka
hi all..
I recently came through this like a statement in AVR c project ,and I was wondering whether it is an augmented assignment or a comparison..
a = ( b() != c );
a = ( b != c );
Any help is much appreciated..
thanks.
BR
Kanishka
The compiler will evaluate :
1. b()
2. compare it with c. true or false.
3. assign the result to a.
I have no idea what an "augmented assignment" is.
Note that the order of evaluation could be completely different if you had changed the parentheses.
David.
"!=" is an operator like any other with a well defined result (0 if both operands are equal, 1 otherwise). And of course it is also possible to assign this result to a variable.
Hi Stefan and David..
Thanks a lot for your reply.
BR
Kanishka
Hi all,
I tried the result to verify this by myself. but the results were not to the expectation..
#includeusing namespace std; int main() { int a,b,c=10; a = (b == c); cout<<a<<"\n"; a = (b != c); cout<<a<<"\n"; }
the output was 0 1 instead of 1 0 which was expected..
anything wrong here.. ??
b has an unspecific random content, so how can you expect something specific?
In your case the random content of b is obviously not 10.
int main() { int a,b,c=10; a = (b == c);
2 of the 3 LOCAL vars. are uninitialized so you can't know what value b will start with. So b == c, tests for equality and is FALSE, etc. from there. You need a good book on C.
Ohhhhh...
Sorry for the silly question and thanks a lot for your help and time..
BR