torkell: (Default)
[personal profile] torkell
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.

Date: 2009-04-16 08:26 pm (UTC)
From: [identity profile] olego.livejournal.com
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

January 2026

S M T W T F S
     123
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 8th, 2026 11:24 am
Powered by Dreamwidth Studios