I am trying to create a TCHAR* variable by using
TCHAR* example = TEXT("example");
but it wont even compile and says: A value of type const wchar_t* cannot be used to initialize an entity of type TCHAR*. What should I do?
I am trying to create a TCHAR* variable by using
TCHAR* example = TEXT("example");
but it wont even compile and says: A value of type const wchar_t* cannot be used to initialize an entity of type TCHAR*. What should I do?
Copyright © 2021 Jogjafile Inc.
You have to add
const, because theTEXT()macro returns a pointer to aconst wchar_t.If the assignment were allowed without the
const, you would be able to modify theconst wchar_tdata through the pointer.See also A value of type "const char*" cannot be used to initialize an entity of type "char *"