Mail Archives: djgpp/1995/05/02/17:15:24
> #include<stdio.h>
> enum{q=1,imax=256};
> main(){double x,y; int i,j,k,l,im=imax;
> printf("A: "); for(i=-im ;i<im ;i++) printf("%d ",i); printf("\n");
> printf("B: "); for(i=-imax;i<imax;i++) printf("%d ",i); printf("\n");}
>
> When this Gnu C++ program runs, loop A prints consecutive numbers on screen
> as expected, but loop B prints <<no numbers at all>>.
First guess would be that imax is interpreted as an unsigned int, messing up
the i<imax test. I'm not sure whether it is legal for the compiler to do
this or not, but, at least in this code fragment, I don't see any reason to
use enum rather than int.
- Raw text -