?

Log in

No account? Create an account
Today's starter for ten: In C++, just how is one meant to go about… - 'Twas brillig, and the slithy toves did gyre and gimble in the wabe [entries|archive|friends|userinfo]
Thomas

[ website | Beware the Jabberwock... ]
[ deviantArt | the-boggyb ]
[ FanFiction | Torkell ]
[ Tumblr | torkellr ]

Links
[Random links| BBC news | Vulture Central | Slashdot | Dangerous Prototypes | LWN | Raspberry Pi]
[Fellow blogs| a Half Empty Glass | the Broken Cube | The Music Jungle | Please remove your feet | A letter from home]
[Other haunts| Un4seen Developments | Jazz 2 Online | EmuTalk.net | Feng's shui]

[Tuesday 14th April 2009 at 5:56 pm]
Thomas

boggyb
Today's starter for ten:

In C++, just how is one meant to go about transforming an integer into a string? Almost every other language I've used can do this in one statement, without having to preallocate the string.
Link | Previous Entry | Share | Next Entry[ One penny | Penny for your thoughts? ]

Comments:
[User Picture]From: olego
Thursday 16th April 2009 at 8:26 pm (UTC)
If you're using STL:

int value = 42;
string string;

stringstream ss; // 1st statement
ss << value; // 2nd statement
ss >> string; // 3rd statement

---

If you're doing Windows programming with MFC:

int value = 42;
CString string;

string.Format("%d", value); // 1 statement
(Reply) (Thread)