"arithmetic if":: Re: Feature for the next C version

Zdenko Tomasic zdenko at csd4.milw.wisc.edu
Sat Jul 29 14:12:36 AEST 1989


In article <8515 at batcomputer.tn.cornell.edu> davidra at tcgould.tn.cornell.edu (David Rabson) writes:
>C does have a generalized "arithmetic if," if you wish, although it is
> .... (switch case , gcc and sun discussion omitted) 
>(This is probably unnecessary, but I rarely get to exercise my 
>FORTRAN.  Can anyone explain the error in the code?)
     yes
>      PROGRAM MAIN
>      INTEGER I
>      READ(5,200) I
>200   FORMAT(I)
              ^ This reserves integer field of only one digit/sign.
		  when you use signed integer, sign is taken, but the
		  magnitude (2nd character and beyond!) is not read!
		  So you program get by fortran conversion -0 which
		  is equivalent to 0. You either have to increase your 
		  integer field length(say I10) and right justify your input
		  (trailing blanks within an integer field are treated as
		  zeros!) or much more conveninetly, use list directed read,
		  i.e. replace the read and format statement above with just
		  READ(5,*) I

>... (the rest of message deleted)
--
___________________________________________________________________
Zdenko Tomasic, UWM, Chem. Dept., P.O. Box 413, Milwaukee, WI 53201
UUCP: uwvax!uwmcsd1!uwmcsd4!zdenko
ARPA: zdenko at csd4.milw.wisc.edu



More information about the Comp.lang.c mailing list