You should read the compiler error messages.
The second and third arguments to MessageBox
have to have the same type. Either you call MessageBoxA
with two char *
, or you call MessageBoxW
with two wchar_t *
.
One fix for your code would be to do MessageBoxA(NULL, buff, "User-id", MB_OK)
.
You are using sprintf_s
incorrectly too, please read its documentation. IMHO it would be better to use the standard function snprintf
:
snprintf(buff, sizeof buff, "%s", id.c_str());
Note that you could do away with buff
entirely and write:
MessageBoxA(NULL, id.c_str(), "User-id", MB_OK);
0
solved Why can’t I display this string on MessageBox? [duplicate]