字符串IP和数字IP互转代码
来源:互联网 发布:破解压缩文件密码软件 编辑:程序博客网 时间:2024/06/18 07:41
void CIpToolsDlg::OnInttocharbutton()
{
struct stIP
{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
}ip;
this->UpdateData (TRUE);
memcpy(&ip,&this->m_IntIp ,sizeof(int));
this->m_CharIp .Format ("%d.%d.%d.%d",ip.a,ip.b,ip.c,ip.d);
this->UpdateData (FALSE);
}
void CIpToolsDlg::OnButtonchartoint()
{
struct stIP
{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
}ip;
this->UpdateData (TRUE);
int oldtop=0;
int rf=this->m_CharIp .Find ('.',0);
if(rf==-1){AfxMessageBox("ip erro1");return;}
ip.a=atoi(m_CharIp.Left (rf).GetBuffer (0));
oldtop=rf;
rf=this->m_CharIp .Find ('.',rf+1);
if(rf==-1){AfxMessageBox("ip erro2");return;}
ip.b=atoi(m_CharIp.Mid(oldtop+1,rf-oldtop-1).GetBuffer (0));
oldtop=rf;
rf=this->m_CharIp .Find ('.',rf+1);
if(rf==-1){AfxMessageBox("ip erro3");return;}
ip.c=atoi(m_CharIp.Mid(oldtop+1,rf-oldtop-1).GetBuffer (0));
ip.d=atoi(m_CharIp.Right (m_CharIp.GetLength ()-rf-1));
memcpy(&m_IntIp ,&ip,sizeof(int));
this->UpdateData (FALSE);
// TODO: Add your control notification handler code here
}
{
struct stIP
{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
}ip;
this->UpdateData (TRUE);
memcpy(&ip,&this->m_IntIp ,sizeof(int));
this->m_CharIp .Format ("%d.%d.%d.%d",ip.a,ip.b,ip.c,ip.d);
this->UpdateData (FALSE);
}
void CIpToolsDlg::OnButtonchartoint()
{
struct stIP
{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
}ip;
this->UpdateData (TRUE);
int oldtop=0;
int rf=this->m_CharIp .Find ('.',0);
if(rf==-1){AfxMessageBox("ip erro1");return;}
ip.a=atoi(m_CharIp.Left (rf).GetBuffer (0));
oldtop=rf;
rf=this->m_CharIp .Find ('.',rf+1);
if(rf==-1){AfxMessageBox("ip erro2");return;}
ip.b=atoi(m_CharIp.Mid(oldtop+1,rf-oldtop-1).GetBuffer (0));
oldtop=rf;
rf=this->m_CharIp .Find ('.',rf+1);
if(rf==-1){AfxMessageBox("ip erro3");return;}
ip.c=atoi(m_CharIp.Mid(oldtop+1,rf-oldtop-1).GetBuffer (0));
ip.d=atoi(m_CharIp.Right (m_CharIp.GetLength ()-rf-1));
memcpy(&m_IntIp ,&ip,sizeof(int));
this->UpdateData (FALSE);
// TODO: Add your control notification handler code here
}
- 字符串IP和数字IP互转代码
- ip地址数字和字符串格式互转
- 字符串IP和数字转换的杂谈
- 字符串IP和数字转换的杂谈
- 字符串IP和数字转换的杂谈
- sql server 和 oracle 中,ip与数字互转
- 笔试:使用fprintf和sscanf 判断IP字符串的正确性和数字IP之间的转换
- IP转数字,数字转IP
- JAVA IP地址与数字互转
- java笔记:ip的数字形式与字符串形式互转方法
- ip地址,字符串、数字格式转换
- 数字字符串是否为合法IP地址
- int 型ip 转 字符串型ip
- 字符串IP转整数IP工具
- 数字转IP地址函数
- 数字音乐平台和电视节目怎么“合谋”玩转IP?
- 字符型IP和数字IP之间的转换
- IP字符串转为int类型存储代码
- 调光器
- 计算机网络概述
- 反射
- wp7工程目录含义介绍
- [ linux ] ubuntu12.04 安装mysql!
- 字符串IP和数字IP互转代码
- 生活中的PV操作
- ios项目icon和default图片命名规则
- 计算机网络物理层
- x264中x264_me_search_ref的被调用分析
- 从UIImage转换到NSData类型
- 计算机网络数据链路层
- VS 中PageLayout 属性设置
- 在真机运行程序的时候提示“Could not launch 'app name'”