[7317] in Athena Bugs
Re: vax 7.2R: gcc
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Fri Mar 15 10:46:18 1991
Date: Fri, 15 Mar 91 10:46:02 -0500
From: "Mark W. Eichin" <eichin@ATHENA.MIT.EDU>
To: jldelcal@ATHENA.MIT.EDU
Cc: bugs@ATHENA.MIT.EDU
In-Reply-To: [7314]
In your code submission to "bugs", you complained about:
scanf("%i", &height); /*an error occurs just after this */
The problem here is the use of %i. You probably mean %d; %i is not defined in
BSD scanf (note to bugs: the file bsd-4.3/common/lib/libc/stdio/doscan.c
probably gives warnings at compile time; at first glance, %i will pass
through this and have non-deterministic behavior, as certain automatic
variables will not get initialized.)
%i *is* defined under System V, specifically:
i an integer is expected; the corresponding argument should be an
integer pointer. It will store the value of the next input item
interpreted according to C conventions: a leading "0" implies octal;
a leading "0x" implies hexadecimal; otherwise, decimal.
(this is from the Apollo Domain/OS System V man page. The Domain/OS BSD man
page doesn't mention it.)
In your example, you probably want %d in any case; if you want the behavior
of %i under BSD you'll probably have to code it yourself.
_Mark_ <eichin@athena.mit.edu>
MIT Student Information Processing Board