[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: C compiler Issue



Sumit Rangawala forced the electrons to say:
> The compiler doesnot give an error in the following code section. Is
> this ansi C compatible? I have tried this out with both gcc and sun
> 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);
>                                         ^^^^
> }

Read up on the unary + operator in your C book. If you don't have one,
get Kernighan & Ritchie, 2nd ed.

The code, in its entirety, is not ANSI compatible. However, the statements
in the main() function are.

Binand