Thread overview
Stupid Question: How to convert int to char[]?
Sep 27, 2002
Russ Lewis
Sep 29, 2002
Walter
Sep 30, 2002
Russ Lewis
Sep 30, 2002
Burton Radons
September 27, 2002
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))) ]


September 29, 2002
"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.


September 30, 2002
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))) ]


September 30, 2002
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.