home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!wupost!monsanto.com!skws02!bcschu
- From: bcschu@skws02.monsanto.com (Brett Schultz)
- Newsgroups: comp.lang.c
- Subject: Re: Convert float to a string ?
- Message-ID: <1992Aug20.172112.1564@tin.monsanto.com>
- Date: 20 Aug 92 17:21:12 GMT
- References: <1992Aug19.212749.21008@overload.lbl.gov>
- Sender: news@tin.monsanto.com (USENET News System)
- Organization: Monsanto Company
- Lines: 35
-
- prem@prem.lbl.gov (Shirdi R. Prem) writes:
- : In article <1992Aug19.204417.13500@tin.monsanto.com> bcschu@skws02.monsanto.com (Brett Schultz) writes:
- : >KSZ@VM.NRC.CA writes:
- : >: Suppose I have a float a=12.4567, how can I convert it into a string including
- : >: 8 characters? i.e. What I want is
- : >
- : >Use sprintf..
- : >
- : >main()
- : >{
- : > float a = 12.4567;
- : > char b[10];
- : >
- : > sprintf(b,"%f\0",a);
- : >}
- : >That'll do it.
- : >Brett
- :
- :
- : sprintf(b,"%f\0",a);
- : ^^^^^^
- : ^^^^^^
- :
- : Are you sure you need a '\0' here............???
- :
- : Prem! (I guess I should've written a test program to find out, )
- : ( rather than posting this.......... )
-
-
- No, I'm not sure if one NEEDS a \0 there, but it surely doesn't hurt to put
- one there, now you KNOW that your string is null terminated.
-
- Let me know if sprintf puts one there anyway, I wasn't sure.
-
- Brett
-