digitalmars.D.learn - How to cast a int to a string?
- Chris Pons (18/18) Mar 06 2012 I'm trying to update a string easily whenever I change a numeric
- H. S. Teoh (10/13) Mar 06 2012 [...]
- Chris Pons (2/14) Mar 06 2012 Thanks, that did the trick.
I'm trying to update a string easily whenever I change a numeric component of the string. I've tried to do this so far with no result: while( testInt < 10 ) string testString = "Test "; int testInt = 0; testString ~= toString(testInt) testInt++; or this: testString ~= cast(string)(testInt) Both of these give an error. This however does not, but it also doesn't seem to update testString I've also tried this: testString ~= cast(char)(testInt); It doens't throw an error, but it doesnt' seem to work either. For the record, i'm not using writln to print to console, this is through SDL and OpenGL so it should be a string.
Mar 06 2012
On Wed, Mar 07, 2012 at 12:13:54AM +0100, Chris Pons wrote:I'm trying to update a string easily whenever I change a numeric component of the string. I've tried to do this so far with no result:[...] Try this: import std.conv; ... int i = 1234; string s = to!string(i); T -- Recently, our IT department hired a bug-fix engineer. He used to work for Volkswagen.
Mar 06 2012
On Tuesday, 6 March 2012 at 23:19:03 UTC, H. S. Teoh wrote:On Wed, Mar 07, 2012 at 12:13:54AM +0100, Chris Pons wrote:Thanks, that did the trick.I'm trying to update a string easily whenever I change a numeric component of the string. I've tried to do this so far with no result:[...] Try this: import std.conv; ... int i = 1234; string s = to!string(i); T
Mar 06 2012