www.digitalmars.com         C & C++   DMDScript  

D - Stupid Question: How to convert int to char[]?

reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
How do you turn a number into is string representation?  And no, I don't
want to use sprintf ;)

--
The Villagers are Online! villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]
Sep 27 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3D94CA10.8F8E957C deming-os.org...
 How do you turn a number into is string representation?  And no, I don't
 want to use sprintf ;)

At the moment sprintf or itoa is it, though I intend to write a set of toString() functions.
Sep 28 2002
parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Good.  I was trying to use toString, and it didn't seem to be working.  I've
implemented by own toString_russ hacks that I'll use until toString gets
implemented.

Walter wrote:

 "Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
 news:3D94CA10.8F8E957C deming-os.org...
 How do you turn a number into is string representation?  And no, I don't
 want to use sprintf ;)

At the moment sprintf or itoa is it, though I intend to write a set of toString() functions.

-- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Sep 30 2002
parent Burton Radons <loth users.sourceforge.net> writes:
Russ Lewis wrote:
 Good.  I was trying to use toString, and it didn't seem to be working.  I've
 implemented by own toString_russ hacks that I'll use until toString gets
 implemented.

Oh, you're using DLI; just use: char [] str = fmt ("%s", value); It works on all values (%s, that is - giving the wrong format code to a type merely falls back on the default). I thought the question was converting from strings to numbers. The result is allocated, but you could have: char [] statfmt (char [] format, generic [] args...) { static char [] buffer; char [] result; result = fmt (format, args...); if (result.length > buffer.length) buffer.length = result.length; buffer [ .. result.length] = result; delete result; return buffer [ .. result.length]; }
 Walter wrote:
 
 
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3D94CA10.8F8E957C deming-os.org...

How do you turn a number into is string representation?  And no, I don't
want to use sprintf ;)

At the moment sprintf or itoa is it, though I intend to write a set of toString() functions.


Sep 30 2002