I have this problem in MSVC2008 MFC. I´m using unicode. I have a function prototype:
MyFunction(const char *)
and I'm calling it:
MyfunFunction(LPCTSTR wChar).
error:Cannot Convert Parameter 1 From 'LPCTSTR' to 'const char *'
How to resolve it?
Since you're using MFC, you can easily let CString do an automatic conversion from char
to TCHAR
:
MyFunction(CString(wChar));
This works whether your original string is char
or wchar_t
based.
Edit: It seems my original answer was opposite of what you asked for. Easily fixed:
MyFunction(CStringA(wChar));
CStringA
is a version of CString
that specifically contains char
characters, not TCHAR
. There's also a CStringW
which holds wchar_t
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With