bug? in turbo c++

Craig Nelson mwizard at eecs.cs.pdx.edu
Mon Mar 11 18:38:55 AEST 1991


ch at dce.ie (Charles Bryant) writes:

>In article <1991Mar6.173733.430 at unhd.unh.edu> rg at msel.unh.edu (Roger Gonzalez) writes:
>>main()
>>{
>>    int     i;
>>    long    j;
>>
>>    for (i = 0; i < 1000; i++, j = i*2)
>>        printf("oh crud: %x %10d %x\r", i, j, i);
>>}

>Surely I am not the only person to notice that j is used before being
>set? (On the first pass only). Maybe our newsfeed is just clogged.
>-- 
>Charles Bryant (ch at dce.ie)

No, you're not the only one.  I wonder if he tried this instead, and then
check for his 'bug':

main()
{ int i=0;j=0;

  for (;i<1000;i++,j=i*2)
      printf("oh crud: %x %10d %x\r", i, j, i);

}

Also,  I was always under the impression that long defaulted to an
integer format (a long one).  I wonder why he is trying to format it
to a double format in the printf() statement ?

Craig Nelson (mwizard at eecs.ee.pdx.edu)



More information about the Comp.lang.c mailing list