I've created a pointer pointing to a couple of chars but after assigning it to some value and then trying to print it on the MessageBox and compiling it is giving me some errors.My code is given below:
#include <Windows.h>
#include <string.h>
#include <iostream>
using namespace std;
void main()
{
char buff[100];
string id = "ST_5";
sprintf_s(buff, "id: %s", id.c_str());
MessageBox(NULL, buff,L"User-id", MB_OK);
}
Please help me in finding the problem in this code, Thanks.
My compiler's output: c:\users\zafri\documents\visual studio 2012\projects\test3\test3\test3.cpp(19): error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [100]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast