How to LPCTSTR Convert to char *
thank :)

What are you trying to do with it? The C in LPCTSTR stands for Constant. So you are maybe better off without changing it's permissions.

I think you need to use _tcscpy() to do the conversion.

Hope this helps

I think you need to use _tcscpy() to do the conversion.

Hope this helps

No. LPCTSTR is defined as const char *. No conversion needed except typecasting to remove the const attribute. Depending upon what is going to be done this may or may not be a good idea.

Example:

int main()
{
  LPCTSTR s = "Hello";
  char *p = const_cast<char*>(s);
  return 0;
}

:o...

Tells you how much I know about Windows programming. :cheesy:

:o...

Tells you how much I know about Windows programming. :cheesy:

No problem -- all of us (except maybe Narue) makes mistakes. :)

No. LPCTSTR is defined as const char *. No conversion needed except typecasting to remove the const attribute. Depending upon what is going to be done this may or may not be a good idea.

Example:

int main()
{
  LPCTSTR s = "Hello";
  char *p = const_cast<char*>(s);
  return 0;
}

thank you ,i write your cord ....

LPCTSTR s = _T("Hello");
char *p = const_cast<char*>(s);

error C2440: 'const_cast' : cannot convert from 'LPCTSTR' to 'char *'

help me ,thank you :)

are you compiling for UNICODE. If you are using VC++ 2005 that is the default.

If yes, then typecasting won't work. you have to use a conversion function to convert from wchar_t* to char*

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.