When I take something as simple as this:
char text1[] = "hello world";
MessageBox(NULL, text1, NULL, NULL);
I get this error:
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [12]' to 'LPCWSTR'
You have two basic problems. First, a char can only hold one character, not a string of characters. Second, you have a "narrow" character string literal, but you're (apparently) using a Unicode build of your application, in which MessageBox expects to receive a wide character string. You want either:
wchar_t text1[] = L"hello world";
or:
wchar_t const *text1 = L"hello world";
or (most often):
std::wstring text1(L"hello world");
...but note that an std::wstring can't be passed directly to Messagebox. You'd need to either pass text1.c_str() when you call MessageBox, or else write a small wrapper for MessageBox that accepted a (reference to) a std::wstring, something like:
void message_box(std::wstring const &msg) {
MessageBox(NULL, msg.c_str(), NULL, MB_OK);
}
#include <string>.MessasgeBox is a macro, it's replacing the name of the MessageBox function above with MessasgeBoxW. Just rename it to something else.A string literal in C/C++ is not a char but a collection of char values. The idiomatic way of declaring this is
const char* text1 = "hello world";
LPCWSTR is referring to a unicode string while char* or LPCSTR refers to an ANSI string. If you need a unicode string use LPCWSTR and change the declaration to L"hello world"char is a single character, not a String.
You need Unicode, you can use TCHAR;
TCHAR[] text = _T("Hello World.");
MessageBox(NULL, text, NULL, NULL);
char only hold one character, not an array of characters.
So just use a pointer to constant string of Unicode characters.
LPCWSTR text1 = L"hello world";
char text1[] = ...is what you are looking for.wchar_t text1[](orstd::wstring).std::string.