Reputation: 6331
I am building a string of int
values, stored in a wchar_t*
. If I have an integer, how can I append it onto the end of a wchar_t*
? Windows only solutions are fine for this and I'd rather not include boost :)
Upvotes: 1
Views: 1329
Reputation: 20495
Use a wide version of stringstream and the '<<' operator. The correct operator to perform the conversion for you should be defined.
If I am missing some subtlety here you could depend on boost and use this.
I'm still a fan of secure versions of sprintf and so is Herb Sutter :D.
Upvotes: 7
Reputation: 264571
How about boost lexical_cast<>
std::wstring data;
data += boost::lexical_cast<std::wstring>(53);
data.c_str() // This is wchar_t*
Upvotes: 0
Reputation: 62333
If you are using windows you can always use wsprintf ie
wsprintf( newStr, L"%s%d", oldStr, yourInt );
I'm sure there will be some equivalent for non-windows ...
Upvotes: 4