From: Ajay Kalra on
It took me a while to get it after reading it few times. I am somehow
convinced that OP got beyond it. I assumed *not working* means goes
beyond compiling and is a run time issue.

---------
Ajay Kalra
ajaykalra(a)yahoo.com

From: Tom Serface on
Hi Tim,

It depends on the compile options you are using. LPCTSTR is safer because
it will morph to be MBCS or Unicode depending on how the program is
compiled.

Tom

"Tim Ward" <tw2(a)ipaccess.com> wrote in message
news:45h2bgF6p7ofU1(a)individual.net...
> "Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
> news:1140017418.811732.197740(a)g14g2000cwa.googlegroups.com...
>>
>> What exactly is the problem? All you are using is the operator LPCTSTR
>> of CString. Show the code that is not working.
>
> Yes, I'd expect that to work better than the
>
>> string Str = (LPCSTR)Temp;
>
> in the original answer.
>
> --
> Tim Ward
> Brett Ward Limited - www.brettward.co.uk
>
>


From: David Wilkinson on
Tom Serface wrote:

> Hi Tim,
>
> It depends on the compile options you are using. LPCTSTR is safer because
> it will morph to be MBCS or Unicode depending on how the program is
> compiled.
>
> Tom
>
> "Tim Ward" <tw2(a)ipaccess.com> wrote in message
> news:45h2bgF6p7ofU1(a)individual.net...
>
>>"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
>>news:1140017418.811732.197740(a)g14g2000cwa.googlegroups.com...
>>
>>>What exactly is the problem? All you are using is the operator LPCTSTR
>>>of CString. Show the code that is not working.
>>
>>Yes, I'd expect that to work better than the
>>
>>
>>>string Str = (LPCSTR)Temp;
>>
>>in the original answer.
>>
>>--
>>Tim Ward
>>Brett Ward Limited - www.brettward.co.uk
>>
>>

Tom:

Yes, but you cannot convert Unicode string to std::string. To get
ANSI-UNICODE compatibility you need to do something like

typedef std::basic_string<TCHAR> tstring;

CString Temp = _T("This is a test");
tstring Str = (LPCTSTR)Temp;

David Wilkinson
From: Ajay Kalra on
I think you are missing Tim's point:

> string Str = (LPCSTR)Temp; // Note LPCSTR instead of LPCTSTR

--------
Ajay Kalra
ajaykalra(a)yahoo.com

From: AliR on
I am a bit lost. Did this finally work or not? And what was the solution?

I personally have used the LPCSTR operator with great success. What to know
if I have been doing the wrong thing all this time.

string str = (LPCSTR)Temp;

AliR.

"Derek" <der(a)yahoo.com> wrote in message
news:egz$UubMGHA.3728(a)tk2msftngp13.phx.gbl...
> Hi,
> How to convert from CString to stl string?
> I tried many things and doesn't work.
> thanks
>
>