Error C2664: 'strcpy' : cannot convert parameter 2 from 'const wchar_t [9]' to 'const char *'.How to solve this error?

前端 未结 1 1169
萌比男神i
萌比男神i 2021-01-29 10:33

How can I get rid of this error and other while compiling the below code?

#include "stdafx.h"
#include 
#include 
#include &         


        
1条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-29 10:50

    Your title says strcpy but your code and errors have FindFirstFile?

    Anyway, declaring your buffer like this will help:

    TCHAR chFolderpath[_MAX_PATH];
    

    Then you will want to use _tcscpy and _tcscat instead of strcpy and strcat. Even better, #include and use the string functions that protect against buffer overrun.

    Regarding AfxMessageBox, this is not a standard Windows function. It's part of MFC, I suppose you cut and pasted from an example that used MFC. Windows has a MessageBox function which you can use, but you'll need to supply all the parameters (parent window, message, title, buttons).

    0 讨论(0)
提交回复
热议问题