VC++ complained wcscpy() at strcpy()?

Stan Huang 421 Reputation points
2021-02-18T08:19:47.713+00:00

An error message:
*1>D:\programs\Neurotek\Neurotec_Biometric_11_2_SDK\Tutorials\Biometrics\CPP\FRV_Dll\FRV_Dll.cpp(514,31): error C2664: 'wchar_t *wcscpy(wchar_t *,const wchar_t *)': cannot convert argument 1 from 'char *' to 'wchar_t '

for the statement "strcpy (retMessage, "test ok");
where retMessage is declared as "char *retMessage".

My statement is "strcpy()", why does it complain about "wcscpy()"?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,636 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Guido Franzke 2,196 Reputation points
    2021-02-18T08:30:05.537+00:00

    Hello,
    it complains because retMessage is of type char* . wcscpy needs type wchar_t . There is no implicit conversion from char* to wchar_t*.
    As I told you before in another thread, I suggest you to use TCHAR and the TCHAR-routines.
    Regards, Guido

    EDIT: oh sorry, you use strcpy already. With char* and "test" the compiler will not complain. Is it really the code that you showed us? Do you really use char* and "test ok" in strcpy?

    0 comments No comments