关于vs2010使用message box 显示string变量的有关问题

关于vs2010使用message box 显示string变量的问题
Vs2010使用message box 显示string变量
如:string str=“mymessage”;
messagebox(str);
提示不能转换成LPCSTR
------解决思路----------------------
str.C_str()
------解决思路----------------------
你不是用的unicode字节序吗?你先确定一下str.C_str()能得到LPCSTR,但是如果用LPWCSTR还得再转
------解决思路----------------------
message box 没有提供std::string作为参数的函数,只能用LPCSTR(多字节下相当于const char *)或者CString类型(这种类型可以隐式转换成前者)

所以想用std::string可以写成str.c_str()将其转换成const char *就可以了