Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 14, 2004 integer to string | ||||
---|---|---|---|---|
| ||||
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 |
July 14, 2004 Re: integer to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simon Hobbs | 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. |
July 14, 2004 Re: integer to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simon Hobbs | 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 way too > heavy and I'd rather not start importing C libraries if I can help it. > > Thanks > > Si > > |
July 14, 2004 Re: integer to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Thanks chaps. |
Copyright © 1999-2021 by the D Language Foundation