#include <windows.h> #include <iostream> using namespace std; int main() { char* file="d:/tester"; WIN32_FIND_DATA FindFileData; HANDLE hFind; hFind = FindFirstFile(file, &FindFileData); // line of error says argument of type char* is incompatible with parameter of type LPCWSTR }
I can not understand the error. What is it and how can I solve this error?
I am making a console application and must check if the files are in a directory.
You call a function that expects a wide string of characters ( FindFirstFileW). You either change the file to use wchar_t* file = L"d:\\tester";, or use the ASCII version of the function FindFirstFileA.
FindFirstFileW
wchar_t* file = L"d:\\tester";
FindFirstFileA
type LPCWSTRis a const pointer to wide char
LPCWSTR
filein char* file="d:/tester";is a pointer to a regular char
file
char* file="d:/tester";
char 1 , char 2 . , ? , . API Windows FindFirstFile, . , L"foo_bar", . wchar_t* file = L"d:\\tester"; , .
FindFirstFile
L"foo_bar"
UNICODE, ANSI . char *
TCHAR * file = TEXT ( "d:\tester" );
.