"Reprint" C + + Compile error C2664: cannot convert parameter 2 from "const char [5]" to "LPCTSTR" solution.

Source: Internet
Author: User

This error occurs when compiling the program because the character set Unicode properties are formatted when you create a new MFC project.

Workaround One:

In the VC2010 Solution Manager window, right-click your project "project", then "Properties" (the last item), then "Configuration Properties", a "+" sign, expand it, then select the "General" tab, the third-lowest "character set", and choose "Use multibyte Character set". Problem solving.

However, it is recommended to use Unicode, otherwise your program will have great limitations, if your program is only in the West, but after all, is adapted to the Chinese mainland procedures, so it is recommended to use Unicode.

Workaround Two:

Use call cstring::allocsysstring ();

For example:

CString str_cap ("haha");
(Const WCHAR *) (Str_cap. AllocSysString ());
(LPCTSTR) (Str_cap. AllocSysString ()); Same effect as above

Http://www.cnblogs.com/qiyebao/archive/2011/12/01/2270951.html

"Reprint" C + + Compile error C2664: cannot convert parameter 2 from "const char [5]" to "LPCTSTR" solution.

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: info-contact@alibabacloud.com 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.