how to convert LPCWSTR and char?

384 views Asked by At
SetTextColor(hdc, RGB(0, 0, 0));
char str[20]="";
sprintf(str, "sorce: %d", sorce);
TextOut(hdc, 930, 810, str,strlen(str));

It showed the error that char* cannot be converted to LPCWSTR. How can I solve it?

1

There are 1 answers

1
Boofhead On

The W in LPCWSTR means wide characters. You have a few options.

You can change from using char types to wchar_t

You can convert using codecvt or Win32 API

Use TextOutA to keep using char types.