Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 27, 2002 Stupid Question: How to convert int to char[]? | ||||
---|---|---|---|---|
| ||||
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 Re: Stupid Question: How to convert int to char[]? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | "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 Re: Stupid Question: How to convert int to char[]? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 Re: Stupid Question: How to convert int to char[]? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | 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. |
Copyright © 1999-2021 by the D Language Foundation