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?
You have to add const
, because the TEXT()
macro returns a pointer to a const wchar_t
.
const TCHAR* example = TEXT("example");
If the assignment were allowed without the const
, you would be able to modify the const wchar_t
data through the pointer.
See also A value of type "const char*" cannot be used to initialize an entity of type "char *"