Convert string type to lpctstr

Source: Internet
Author: User

See the following link:



The lpctstr is not a type, but a type of two: one of the two types: lpcstr and the other. It will become one of the two based on whether your current program uses the Unicode Character Set. If the Unicode character set is used, the value of this parameter is "maid". Otherwise, the value of this parameter is "maid.


Converting the STD: string in the standard library to the lpcstr is simple: directly call c_str. Example:

STD: string a = "ABC ";

Lpcstr STR = A. c_str ();


The standard library also has a wstring, which represents the string of the wide character. Converting STD: wstring to lpcwstr is also very easy:

STD: wstring A = L "ABC ";

Lpcwstr STR = A. c_str ();


If you want to convert STD: string to lpcwstr or STD: wstring to lpcstr, you need to call multibytetowidechar or widechartomultibyte to convert character sets. However, in most cases, this type of cross conversion is not required. A program generally uses only one character set.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.