Click to See Complete Forum and Search --> : operator LPCTSTR


Normen Müller
May 19th, 1999, 06:57 AM
Hi!

How do I have to use this string operator?
I have a CString object i.e. "s" and now I want to access the characters stored in this object.
I do not want to use the member function "GetBuffer( )".

Thanx in advance...
Normen

--
apartis AG http://www.apartis.de
Normen Mueller

Franky Braem
May 19th, 1999, 07:03 AM
like this :

LPCTSTR lpTest = (LPCTSTR) MyCString;

It's a cast-operator.

Syelixn
May 19th, 1999, 11:00 AM
If you feel more comfortable with C style of accessing strings, cast it to char type first.
E.g.

CString s="My String";
char *cpBuffer;

cpBuffer=new char[s.GetLength()+1];
strcpy(cpBuffer, (LPCTSTR)s);
... // do character by character access
delete []cpBuffer;