string 转化为其他类型

string str = "11";

 

string转化为CString cstr;
cstr.format("%s", str.c_str());

 

string转化为char* ch;
ch = string.c_str(); 
/*
string.c_str()只能转换成const char *,
要转成char *这样写:
string mngName;
char t[200]; memset(t,0,200); strcpy(t,mngName.c_str());
*/

 

string转化为byte
BYTE *pBy = new BYTE[str.GetLenght()];
sprintf(pBy,"%s",str);

posted @ 2009-12-14 16:18  傲衣华少  阅读(180)  评论(0编辑  收藏  举报