
Hi,
What is the best way to concatanate an integer to wstring?
for example
===========
std::wstring ws=L"str";
for(int i=0;i<10;++i)
{
cout<

AMDG Lloyd wrote:
What is the best way to concatanate an integer to wstring?
for example ===========
std::wstring ws=L"str";
for(int i=0;i<10;++i) { cout<
The output could be str1 str2 .... str9
ws + boost::lexical_caststd::wstring(i)? In Christ, Steven Watanabe

On Thu, Nov 12, 2009 at 1:35 PM, Steven Watanabe
AMDG
Lloyd wrote:
What is the best way to concatanate an integer to wstring?
for example ===========
std::wstring ws=L"str";
for(int i=0;i<10;++i) { cout<
The output could be str1 str2 .... str9
ws + boost::lexical_caststd::wstring(i)?
In Christ, Steven Watanabe
Or in this particular example: cout << ws << i; although I'm not sure if that's what the OP is really getting at.

Thanks, it works...
On Fri, 13 Nov 2009 01:05:44 +0530, Steven Watanabe
AMDG
Lloyd wrote:
What is the best way to concatanate an integer to wstring?
for example ===========
std::wstring ws=L"str";
for(int i=0;i<10;++i) { cout<
The output could be str1 str2 .... str9
ws + boost::lexical_caststd::wstring(i)?
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
______________________________________ Scanned and protected by Email scanner

Or use stringstreams (which is, I believe, how lexical_cast is implemented).
It should look something like this:
std::wstringstream oss;
std::wstring mystr;
std::wstring ws=L"str";
for(int i=0;i<10;++i)
{
oss << ws << i;
}
mystr=oss.str();
std::cout << mystr;
On 11/12/09, Lloyd
Thanks, it works...
On Fri, 13 Nov 2009 01:05:44 +0530, Steven Watanabe
wrote: AMDG
Lloyd wrote:
What is the best way to concatanate an integer to wstring?
for example ===========
std::wstring ws=L"str";
for(int i=0;i<10;++i) { cout<
The output could be str1 str2 .... str9
ws + boost::lexical_caststd::wstring(i)?
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
______________________________________ Scanned and protected by Email scanner _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Chris Johnson
-
Lloyd
-
Steven Watanabe
-
Zachary Turner