[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: C compiler Issue
On Thu, 8 Feb 2001, Sumit Rangawala wrote:
> compiler on solaris. The result is the same -- no error. And when
> executed, the result is 18.
> There is a space between the two + sign.
>
> #include <stdio.h>
> int main()
> {
> int i=5,j=6,k=7;
> printf("%d\n", i + 6 + + k);
> ^^^^
> }
The lexical analyser treats the first + as binary operator
(because of space). It is equivalent to (i+6)+ (+ k). Hence value is
18. If there is no space it should give an error.
Thus i + + + + j = i+j , i + ++ j = i + (++j) ,i ++ +j = i++ + j(++ to i)
--samba