Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!math.fu-berlin.de!opal!tmpmbx!unlisys!dobag.in-berlin.de!einoed!fub!kirste From: kirste@methan.chemie.fu-berlin.de (Burkhard Kirste) Newsgroups: comp.lang.c Subject: Re: bug? in turbo c++ Message-ID: Date: 7 Mar 91 12:11:57 GMT References: <1991Mar6.171424.17409@nntp-server.caltech.edu> <1991Mar6.173733.430@unhd.unh.edu> Organization: Free University of Berlin, Organic Chemistry Lines: 27 rg@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@kristall.chemie.fu-berlin.dbp.de /FUB\ Takustrasse 3, D-1000 Berlin 33 UUCP: kirste@fub.uucp `---' Telefon: (030)838-6484 Telefax: (030)838-5163