Mateusz
Thu Jun 21 21:32:38 CDT 2007
On Fri, 22 Jun 2007 03:08:58 +0200, Carol <Carol.Hu.Mail@gmail.com> wrote:
> I know CString has a powful method Replace(), is there any similiar
> method for replacement in tstring?
>
> My problem is I got a TCHAR[] in my code, and I need to replace a
> substring of it. It seems I should use tstring, but I didn't find any
> Replace() method in tstring...
I'm not sure what you mean as tstring but here is my version
based on the standart string tempalate:
#include <iostream>
#include <string>
#include <tchar.h>
typedef std::basic_string<TCHAR, std::char_traits<TCHAR>,
std::allocator<TCHAR> > tstring;
int main()
{
tstring s(_T("abcdef"));
s.replace(s.find(_T("cd")), 2, _T("12"));
std::wcout << s << std::endl;
return 0;
}
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net