digitalmars.D - integer to string
- Simon Hobbs (8/8) Jul 14 2004 Is there a simple way to convert an integer to a string?
- Stewart Gordon (8/17) Jul 14 2004 The undocumented function std.string.format makes it easy:
- Ben Hinkle (6/14) Jul 14 2004 import std.string;
- Simon Hobbs (1/1) Jul 14 2004 Thanks chaps.
Is there a simple way to convert an integer to a string? I'm trying to do something along the lines of: int i; char[] s = "i = " ~ i; The only thing I can see in phobos is the std.format stuff, but that's way too heavy and I'd rather not start importing C libraries if I can help it. Thanks Si
Jul 14 2004
Simon Hobbs wrote:Is there a simple way to convert an integer to a string? I'm trying to do something along the lines of: int i; char[] s = "i = " ~ i; The only thing I can see in phobos is the std.format stuff, but that's way too heavy and I'd rather not start importing C libraries if I can help it.The undocumented function std.string.format makes it easy: char[] s = format("i = ", i); Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 14 2004
import std.string; ... char[] s = "i = " ~ toString(i); "Simon Hobbs" <Simon_member pathlink.com> wrote in message news:cd3f82$1ve2$1 digitaldaemon.com...Is there a simple way to convert an integer to a string? I'm trying to do something along the lines of: int i; char[] s = "i = " ~ i; The only thing I can see in phobos is the std.format stuff, but that's waytooheavy and I'd rather not start importing C libraries if I can help it. Thanks Si
Jul 14 2004