int转string string转int CString转Char*

来源:互联网 发布:windows一键还原密码 编辑:程序博客网 时间:2024/06/05 02:21

int转string

int n;string s;stringstream stream;stream << n;stream >> s;

string转int

int n;string s;n = atoi(s.c_str());

CString转Char*

char* CStringToCharArray(CString str){char *ptr;#ifdef _UNICODELONG len;len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);ptr = new char [len+1];memset(ptr,0,len + 1);WideCharToMultiByte(CP_ACP, 0, str, -1, ptr, len + 1, NULL, NULL);#elseptr = new char [str.GetAllocLength()+1];sprintf(ptr,_T("%s"),str);#endifreturn ptr;}