方法一:
//m_Ip为IP Address控件的变量名
m_Ip.GetAddress(IPByte[0],IPByte[1],IPByte[2],IPByte[3]); 获得IP Address控件中的4部分数字
//------------------把IP地址转化为字符
CString strI;="";
char temp1[10],temp2[10],temp3[10],temp4[10];
itoa(IPByte[0],temp1,10);
itoa(IPByte[1],temp2,10);
itoa(IPByte[2],temp3,10);
itoa(IPByte[3],temp4,10);
strIp+=temp1;
strIp+=".";
strIp+=temp2;
strIp+=".";
strIp+=temp3;
strIp+=".";
strIp+=temp4;
-----------------------
_itoa函数介绍
定义在stdlib中的 , _CRTIMP char * __cdecl _itoa(int, char *, int);
我看的源代码中是这么调用的:
_itoa(i,str3,10);
功能:把整形转换为字符类型,
含义: i:需要转换的整形
str3:字符串缓冲区
10:十进制方式
----------------
方法二(简单):
m_IP.GetAddress(f0,f1,f2,f3);//m_IP是ip控件的控制变量
m_addr.Format("%d%s%d%s%d%s%d",f0,".",f1,".",f2,".",f3);
使用VC提供的Format函数,省去了整数转化为字符串的操作。--------