Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!cica!news.cs.indiana.edu!ariel.unm.edu!pprg.unm.edu!topgun!mustang!nntp-server.caltech.edu!iago.caltech.edu!gceych From: gceych@iago.caltech.edu (Eychaner, Glenn C.) Newsgroups: comp.lang.c Subject: Re: sprintf badness Keywords: sprintf, sscanf Message-ID: <1991Jan21.004401.15257@nntp-server.caltech.edu> Date: 20 Jan 91 23:37:46 GMT References: <473@bally.Bally.COM> Sender: news@nntp-server.caltech.edu Reply-To: gceych@iago.caltech.edu Distribution: usa Organization: California Institute of Technology Lines: 24 News-Software: VAX/VMS VNEWS 1.3-4x Nntp-Posting-Host: iago.caltech.edu siva@bally.Bally.COM (Siva Chelliah) writes... > I am running into problems when I mix floats and integers in sprintf. No. You are running into problems when you mix floats and doubles in scanf and sprintf. > double k; ^^^^^^^^ Note that k is declared as double. > sscanf(buf,"%4d%7f%4d",&i,&k,&j); ^^^ I believe this should be "%7lf", for a DOUBLE number. Same mistake is made in the next line of the program. > printf("i = %d j = %d k= %7.2f",i,j,k); ^^^^^ Sorry for posting this.....but it illustrates a BAD HABIT of confusing float with double (a habit I used to have). Glenn C. Eychaner | "Do you qualify to be alive, or is the limit of your senses 40386 N. Shore Ln `-----. so as only to survive?" -R.Stevens, _Mr.Businessman_ Big Bear City, CA 92314 `-----------------------. !**** G O N I N E R S ****! Eychaner%SunCub.Caltech.edu@Xhmeia.Caltech.edu -|- Big Bear Solar Observatory