0

Possible Duplicate:
char array to LPCTSTR conversion in c
how can convert LPCSTR string into LPCTSTR string?

There is lot of material available already but I am new to C++ so I couldn't understand them properly. Please help.

Community
  • 1
  • 1
Abhi9
  • 59
  • 8
  • If `UNICODE` is not defined, then `const char *` is the same thing as `LPCTSTR`. – Dietrich Epp Sep 25 '12 at 09:15
  • 1
    @DietrichEpp: But that would be a bad idea. – MSalters Sep 25 '12 at 09:16
  • If you atleast bothered to search, you'd find [this](http://stackoverflow.com/questions/976568/char-array-to-lpctstr-conversion-in-c) – Indy9000 Sep 25 '12 at 09:17
  • I have searched every where but as I am new to this i couldn't get them properly. It was last option to ask here but things are same. Thanks anyways – Abhi9 Sep 25 '12 at 09:30

1 Answers1

0

google gave me this link, with a lot of information.

The type-name LPCTSTR can be classified as:

LP - Pointer
C - Constant
T = TCHAR
STR = String

Depending on the project settings, LPCTSTR would be mapped to either LPCSTR (ANSI) or LPCWSTR (Unicode).

The type-name LPCSTR can be classified as:

LP - Pointer
C - Constant
STR = String

A STR is the same as a char*

The type-name LPCWSTR can be classified as:

LP - Pointer
C - Constant
WSTR - Wide character String

here a WSTR is a wchar_t* or a wide char (2 byte char)

And last but not least this article on how to do the conversion. As you can see there is a bit more to it that a simple type conversion.

Minion91
  • 1,911
  • 12
  • 19
  • 1
    LPCTSTR isn't another name for a `const char*`. It's a name for `const char*` or `const wchar_t*` (or even 'const unsigned short*`) depending on your compilation options. – JoeG Sep 25 '12 at 09:18
  • Please elaborate when you downvote – Minion91 Sep 25 '12 at 09:18
  • -1 doesn't actually explain how to convert `const char *` to `LPCTSTR`, and the tone sounds rather grumpy for no good reason. – Frerich Raabe Sep 25 '12 at 09:28
  • Thanks Minion91 for explaination. By saying LPCTSTR is another name for a const char * do you mean, i can do this char abc[]; LPCTSTR xyz = abc; – Abhi9 Sep 25 '12 at 09:35
  • The first post was actually a bit faulty, this update one should provide you with everything you need – Minion91 Sep 25 '12 at 09:37