Date: Mon, 29 Mar 1999 15:05:52 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: ryan_brown AT my-dejanews DOT com cc: djgpp AT delorie DOT com Subject: Re: Converting between varable types In-Reply-To: <7dlh6c$4b3$1@nnrp1.dejanews.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sun, 28 Mar 1999 ryan_brown AT my-dejanews DOT com wrote: > How do you convert data between variables of different types? I need to > convert the data in a float variable to a char variable. In pascal you could > just use funcitons like FloatToStr() however in c I can't find anything. This isn't ``conversion to a char'', this is generation of a printable text representation of a float number. The way it is done in C is with the `sprintf' function. It takes an address of a char buffer, a format specifier (use %f if you don't have any special requirements), and the number, and puts the text representation into the buffer. Another possibility is to use the `fcvt' and `gcvt' functions, but they usually are not what you'd want. All these functions are described in detail in the library reference (type "info libc alpha sprintf" from the DOS prompt and read there).