Knowledge Point: CString turn char*,stringstring Turn char*, CStringChar* Turn CString,stringOne, CString turn char*,string //String Conversion testCString CString1; STD::stringstring1; CHAR* char1=NULL; //1string1=Cstring1.getbuffer (); Cstring1.releasebuffer (); //2char1=Cstring1.getbuffer (); Cstring1.releasebuffer (); second, string to char*, CString//1cstring1=String1.data (); //2char1=NewChar[string1.length () +1]; strcpy (Char1,string1.data ()); third, CHAR*Turn cstringwstring CString1=char1; String1=char1; ////TODO: Add control notification handler code here //CString cstring1= "CString"; //std::string string1= "string"; //CHAR * char1= "char1"; ////One, CString string, char* //string1=cstring1; //Char1=cstring1.getbuffer (); //Cstring1.releasebuffer ();//releasing a string buffer ////Two, string to CString char* //string1= "string1"; //Cstring1=string1.data (); ////char1=string1.data (); //new Char[string1.length () +1]; //strcpy (Char1,string1.data ()); ////Three, char* turn CString, String //char1= "Char1"; //cstring1=char1; //string1=char1; ////TODO: Add control notification handler code here //CString cstring1=l "CString"; //std::wstring string1=l "string"; //WCHAR * char1=l "char1"; ////One, CString string, char* //string1=cstring1; //Char1=cstring1.getbuffer (); //Cstring1.releasebuffer ();//releasing a string buffer ////Two, string to CString char* //string1=l "string1"; //Cstring1=string1.data (); ////char1=string1.data (); //new Wchar[string1.length () +1]; //wcscpy (Char1,string1.data ()); ////Three, char* turn CString, String //char1=l "Char1"; //cstring1=char1; //string1=char1; //TODO: Add control notification handler code hereCString cstring1= _t ("CString"); STD::stringstring1=_t ("string"); TCHAR* CHAR1=_T ("char1"); //one, CString string, char*string1=CString1; Char1=Cstring1.getbuffer (); Cstring1.releasebuffer ();//releasing a string buffer//Second, string to CString char*string1=_t ("string1"); CString1=String1.data (); //Char1=string1.data (); NewTchar[string1.length () +1]; strcpy (Char1,string1.data ()); //third, char* turn CString, Stringchar1=_t ("char1"); CString1=char1; String1=CHAR1;
Conversion between MFC cstring,string,char*