www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/15/22:43:14

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Long -> String
Date: Fri, 15 Nov 1996 21:11:04 -0800
Organization: Three pounds of chaos and a pinch of salt
Lines: 31
Message-ID: <328D4CE8.F0@cs.com>
References: <328CDB1A DOT 7F2E AT abc DOT se>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp101.cs.com
Mime-Version: 1.0
To: Henrik DOT Baarnhielm AT abc DOT se
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Henrik Bäärnhielm wrote:
> 
> Is there a library function that convert a long to a string? In for
> example Turbo C++ 3.0 which I have coded in pretty much, there are ultoa
> that converts unsigned long to string and gcvt that converts float to
> string. I have looked in the library reference but I can't find
> something that does that.

char str[100];
long l = 100;

sprintf( str, "%ld", l );

You could easily write an "ltoa()" function that does this and put it in
your programs.  There is no such function in DJGPP because it is
non-ANSI.

P.S.:  Since ints in DJGPP are 4-byte anyway, itoa() is easily capable
of handling a long.

-- 
John M. Aldrich <fighteer AT cs DOT com>                      

* Anything that happens, happens.
* Anything that, in happening, causes something else to happen,
  causes something else to happen.
* Anything that, in happening, causes itself to happen again, happens
  again.
* It doesn't necessarily do it in chronological order, though.
 
                                       --- Douglas Adams

- Raw text -


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