c++ 中 string 转char
来源:百度知道 编辑:UC知道 时间:2024/05/22 19:10:47
#include "stdafx.h"
#include "dr.h"
#include <string>
using namespace std;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
string str;
str="加载成功!";
char p[]=str.c_str();
//id=GetCurrentProcessId();
MessageBox(NULL,p,"提示信息",MB_OK);
break;
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
{
MessageBox(NULL,"卸载!","提示信息",MB_OK);
break;
}
}
return TRUE;
}
组建的时候报错:
--------------------Configuration: dr - Win32 Debug--------------------
Compiling...
dr.cpp
d:\My Documents\VC\dr\dr.
#include "dr.h"
#include <string>
using namespace std;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
string str;
str="加载成功!";
char p[]=str.c_str();
//id=GetCurrentProcessId();
MessageBox(NULL,p,"提示信息",MB_OK);
break;
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
{
MessageBox(NULL,"卸载!","提示信息",MB_OK);
break;
}
}
return TRUE;
}
组建的时候报错:
--------------------Configuration: dr - Win32 Debug--------------------
Compiling...
dr.cpp
d:\My Documents\VC\dr\dr.
1.
MessageBox(NULL, str.c_str(),"提示信息",MB_OK);
2.
const string str = "加载成功";
char szBuf[100];
strcpy( szBuf, str.c_str() );
MessageBox(NULL, szBuf提示信息",MB_OK);
关于c++ String建议你查看我写的《c++ String深入详解2.0版》PDF:
http://hi.baidu.com/_%E2d_%B7%B3_%DE%B2%C2%D2/blog/item/9d24e20196e43604728da547.html
.net(C#)中String.Format如何使用
string与String有什么不同?(c#)
C语言中有string类型变量吗?
关于c里面的string.h
c#.net怎么在某个access数据文件中创建一个含有string类型字段的表
c++builder中如何区分一个String串中的字母数字和汉字?
编程问题:string类怎么保存到二进制文件中?(C++)
C#中string path =@"c:\aa";这个@起什么作用?
C语言中printf("\n No enough memory to allocata for the string.");的意义
用C语言printf()怎么输出string型?整型是%d,那么string型的是%?