|
Boost Users : |
Subject: Re: [Boost-users] concat integer to wstring
From: Chris Johnson (plasticchris_at_[hidden])
Date: 2009-11-14 02:41:36
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 <lloyd_at_[hidden]> wrote:
> Thanks, it works...
>
> On Fri, 13 Nov 2009 01:05:44 +0530, Steven Watanabe <watanabesj_at_[hidden]>
> 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<<ws+i;
>>> }
>>>
>>> The output could be
>>> str1
>>> str2
>>> ....
>>> str9
>>
>> ws + boost::lexical_cast<std::wstring>(i)?
>>
>> In Christ,
>> Steven Watanabe
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> ______________________________________
> Scanned and protected by Email scanner
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net