1.IP 控件的IP 值转化为CString 类型 CIPAddressCtrl *c=(CIPAddressCtrl *)(GetDlgItem(IDC_IPADDRESS1)); c->GetAddress(m_bIPAddress[0],m_bIPAddress[1],m_bIPAddress[2],m_bIPAddress[3]); // m_bIPAddress[0]为BYTE 类型,需要在类中定义public FileServerIP1.Format("%d",(int)m_bIPAddress[0]); FileServerIP2.Format("%d",(int)m_bIPAddress[1]); FileServerIP3.Format("%d",(int)m_bIPAddress[2]); FileServerIP4.Format("%d",(int)m_bIPAddress[3]); FileServerIP=FileServerIP1+"."+FileServerIP2+"."+FileServerIP3+"."+FileServerIP4; 2. CString 类型转换为float,int,dou ble 类型 CString strval; strval="12.43aa"; char* pChar1=strval.GetBuffer(strval.GetLength()); float fval=atof(pChar1); double dval=atof(pChar1); int ival=atoi(pChar1); 3. float,int,dou ble 类型转换为CString 类型 CString total_str[3],pass_str[3],yield_str[3]; for(int i=0;i<3;i++) { total_str[i].Format("%d",total[i]); pass_str[i].Format("%d",pass[i]); yield_str[i].Format("%f",yield[i]); } 4. string 类型转化为dou ble,int,char类型 string strvar="3.1415926aa"; double dvar=atof(strvar.c_str()); cout<<"convert string to double "<