bug? in turbo c++

Burkhard Kirste kirste at methan.chemie.fu-berlin.de
Thu Mar 7 22:11:57 AEST 1991


rg at msel.unh.edu (Roger Gonzalez) writes:

>the following program demonstrates this "bug":
>main()
>{
>    int     i;
>    long    j;
>
>    for (i = 0; i < 1000; i++, j = i*2)
>        printf("oh crud: %x %10d %x\r", i, j, i);
>}
>
>The third number printed is always zero.  It corrects itself if the
>second formatting string is %10ld.  Is this a new ansi-ism?  Will this
>behavior change to what my Unix cc fingers expect if I set it to K&R?
>Is it a bug?  I can see them arguing that it isn't a bug, but I find
>it an unpleasant nonbug at the very least.
>
Under UNIX, it doesn't matter: int = long = 32 bit (usually),
although you have to specify %hd for short int (16 bit).
Otherwise, if int = 16 bit, long = 32 bit, you have to use
%ld for long. That is simply logical, not a "bug"!
-- 
  |~|   Freie Universitaet Berlin, Institut fuer Organische Chemie
  / \   Burkhard Kirste    kirste at kristall.chemie.fu-berlin.dbp.de
 /FUB\  Takustrasse 3, D-1000 Berlin 33      UUCP: kirste at fub.uucp
 `---'  Telefon: (030)838-6484              Telefax: (030)838-5163



More information about the Comp.lang.c mailing list