MessageBox error

Nov 27, 2016 at 3:28am
What do I need to do to get "message" in the messagebox without
any weird characters.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <windows.h>

using namespace std;

int main(){

    string message = "message";

    MessageBoxA(NULL, (char*)&message, (char*)&message, MB_ICONERROR);

}
Nov 27, 2016 at 3:48am
If you're running in Unicode:
1
2
wstring wmessage{ message.begin( ), message.end( ) };
MessageBoxA( NULL, wmessage.c_str( ), wmessage.c_str( ), MB_ICONERROR );


Otherwise:
 
MessageBoxA( NULL, message.c_str( ), message.c_str( ), MB_ICONERROR );
Nov 27, 2016 at 3:50am
Great ! Thanks man your a hero.
Topic archived. No new replies allowed.