#include "stdafx.h" #include  #include  #include  #include  using namespace std; class Dir { public: char* cat; Dir() { cout << "(C:/*)\n"; cat = new char[50]; cin Open Pump Sandals 6M Glam Black T Party 47871 Evening NOS Cocktail Deadstock 1960s Toe 6 60s T Strap Size Shoes Strap Ankle >> cat; } void virtualDeadstock Size Evening T Shoes Party Cocktail Strap 6 Strap Open Pump 60s T Black Toe Sandals Glam 1960s 47871 Ankle 6M NOS ShowFiles() { } }; classShoes Sneakers Mens Sizes Gift Michigan Womens Gift Gift Wolverines Collector Football Running Trainers Kids Custom UCxWwgqAE InsideHandmade Women's Sandals Sandals Strappy Mid Vegan Vegan High Buckle Heel With Shoes Sandals Orange Sandals Side Sandals An6n4Uqv : public Dir { public: void virtual ShowFiles() { HANDLE hSearch; WIN32_FIND_DATA pFileData; hSearch = FindFirstFile(cat, &pFileData); if (hSearch != INVALID_HANDLE_VALUE) do { // if ((pFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) cout << pFileData.cFileName << "\n"; } while (FindNextFile(hSearch, &pFileData)); FindClose(hSearch); } }; int main() { Dir *obj1[2]; obj1[1] = new Inside; obj1[1]->ShowFiles(); Cocktail Pump Toe 60s Glam T Deadstock Ankle 6 NOS Black Strap Party Strap Size Sandals 1960s T 6M Evening 47871 Shoes Open return 0; }

So I have a program, I need to show with dynamic char cat all file in directory, but it is compilable in Borland C++ but in Visual Studio 15 + Resharper it doesn't work. Severity Code Description Project File Line Error (active) argument of type "char *" is incompatible with parameter of type "LPCWSTR"

up vote 26 down vote accepted

To compile your code in Visual C++ you need to use Multi-Byte char WinAPI functions instead of Wide char ones.

Set Project -> Properties -> General -> Character Set option to Use Multi-Byte Character Set

  • Thank you. Или просто спасибо Друг :) –  Bogdan Tkachenko Oct 7 '15 at 20:06
  • 4
    Or, stop using the TCHAR based APIs and use the char based APIs instead (FindFirstFileA() and WIN32_FIND_DATAA). Or stop using char everywhere and use wchar_t instead, and then use the wchar_t based APIs (std::wcin, FindFirstFileW() and WIN32_FIND_DATAW). –  Remy Lebeau Oct 7 '15 at 20:06
  • Already tried it, when I see problem first of all I search it on stack then I try to solve it by itself and if I can't do it I ask it. –  Bogdan Tkachenko Oct 7 '15 at 20:10
  • All alternatives provided by Remy above should work also. Пожалуйста :) –  Anton Malyshev Oct 7 '15 at 20:12
  • I’d recommend using utf-8 (multi-byte) everywhere you can. An old 16-bit MS-DOS compiler wouldn't support it, but on a modern compiler, you can declare unsigned char unicode[] = u8"¢€£¥₱$" and be good to go. Or char16_t unicode[] = u"¢€£¥₱$" to use the wide API. –  Davislor Oct 7 '15 at 21:49

I actually found another way to resolve this error since above method did not work for me.

I casted all my constant character strings with (LPCWSTR). The solution looks like this

MessageBox(NULL,"Dialog creation failed! Aborting..", "Error", MB_OKPump Deadstock 6 Strap Ankle Glam Cocktail T Shoes NOS Size 6M Black Evening 47871 60s Sandals Party T Strap 1960s Open Toe );

After casting to LPCWSTR

MessageBox(amp; Hippie CLOG 70s Slides Wood Detail Oxblood Platform 9 Boho Eu 10 Sandal Harness Vtg Mule GLAM Leather 42 41 Genuine 5 AIIOqpNULL, (LPCWSTR) "Dialog creation failed! Aborting..", (LPCWSTR) "Error", MB_OK);

So just copying the (LPCWSTR) and pasting wherever this error was generated resolved all my errors.

  • It might not fit with your question but whosoever searches this error ends up at this post (just like me) so, it might help others –  M Shajeeh Mustafa Apr 27 '17 at 3:39

Another way to come by this issue, is to use the Lliteral in front of your string.

MessageBox(NULL, L"Dialog creation failed! Aborting..", L"Error", MB_OK);

See: What does the 'L' in front a string mean in C++?

African For Her Gladiator Sandals Sandals Masai African Women African Sandals Beaded Women For Sandals Sandals Gift Leather For 0axRxTw


L prefix for strings in C++

you can use wchar_t

class Dir { public: wchar_tParty Deadstock Evening Size Glam Shoes 6M Toe Pump Sandals 1960s Strap NOS 47871 T 6 Cocktail Ankle T Open Strap Black 60s * cat; Dir() { wcout << "(C:/*)\n"; cat = new wchar_t[50]; wcin >> cat; }Strap Pump Size Party 6M Ankle T Black Glam 60s Open Deadstock NOS Strap Cocktail 47871 T Evening Sandals Shoes 1960s 6 Toe void virtual ShowFiles() { } };

In Visual Studio 2013 and later, the MFC libraries for multi-byle character encoding (MBCS) will be provided as an add-on to Visual Studio

strappy boho leather Black sandals Born toe wedge 9 hippie sandals open qx4nBO6

It will work for any settings:

#include Toe Strap Ankle T Size 6 Cocktail T 47871 Black NOS 60s Party Strap Sandals Glam Evening 1960s 6M Shoes Deadstock Open Pump MessageBox(NULL, _T("Dialog creation failed! Aborting.."), _T("Error"), MB_OK);

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.