weird C behavior

Tom Dube dube at csd2.UUCP
Sun Mar 23 04:01:00 AEST 1986


>Here is a short C program which gives correct output according to K & R.
>While I can't argue it's wrong, it is not transparently right, either.
>#include <stdio.h>
>#define BIG 36864
>int i;
>i = BIG;
>if (i != BIG)
>   printf("Equality NOT found: i = %d, BIG = %d\n", i, BIG);

 Sure it's correct. i is not 36864 because it is forced into a 16
bit integer.  The numbers look the same when you print them because
you are also forcing BIG into an integer with the format %d.  Try
printing both numbers with %ld.
                                    Tom Dube



More information about the Comp.lang.c mailing list