www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/20/15:31:42

From: sparhawk AT eunet DOT at (Gerhard Gruber)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: float convertion
Date: Fri, 19 Jun 1998 23:17:00 GMT
Organization: Customer of EUnet Austria
Lines: 43
Message-ID: <3593f131.28169196@news.Austria.EU.net>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980618100118 DOT 23552N-100000 AT is> <358A9BD9 DOT ECDC01C5 AT wambooli DOT com>
NNTP-Posting-Host: e117.dynamic.vienna.at.eu.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Destination: Dan Gookin <dgookin AT wambooli DOT com>
From: Gruber Gerhard
Group: comp.os.msdos.djgpp
Date: Fri, 19 Jun 1998 10:11:54 -0700:

>Eli Zaretskii wrote:
>
>> On Thu, 18 Jun 1998, Jonathan Villani wrote:
>>
>> > Hi! I am currently programming 3d stuff and I would like to know how
>> to
>> > convert a float to a string. I know that in Borland C there was a
>> function
>> > called fcvt. In DJGPP, I don't know if it is possible???
>>
>> fcvt is non-standard, and DJGPP doesn't have it.  Use sprintf instead.
>
>Or you can use fprintf to "save" the value to disk, then read it back in
>as a string:
>
>    fprintf(handle,"%f",pi);
>
>Then read it with:
>
>    fgets(string,80,handle);
>
>It's kloogy, but it works.

That's AWFULL. :)
you can do it faster this way.

char s[100];
sprintf(s, "%f", value);

That's it.
--
Bye,
   Gerhard

email: sparhawk AT eunet DOT at
       g DOT gruber AT sis DOT co DOT at

Spelling corrections are appreciated.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019