IP的int型与char*型相互转化
来源:互联网 发布:电脑连接网络错误651 编辑:程序博客网 时间:2024/05/16 18:08
<pre name="code" class="cpp">char * int2ipstr (const int ip, char *buf){sprintf (buf, "%u.%u.%u.%u",(char) * ((char *) &ip + 0),(char) * ((char *) &ip + 1),(char) * ((char *) &ip + 2), (char) * ((char *) &ip + 3));return buf;};
<pre name="code" class="cpp">uint32_t IPToValue(const string& strIP){uint32_t a[4];string IP = strIP;string strTemp;size_t pos;size_t i=3;do{pos = IP.find(".");if(pos != string::npos){strTemp = IP.substr(0,pos);a[i] = atoi(strTemp.c_str());i--;IP.erase(0,pos+1);}else{strTemp = IP;a[i] = atoi(strTemp.c_str());break;}}while(1);uint32_t nResult = (a[3]<<24) + (a[2]<<16)+ (a[1]<<8) + a[0];return nResult;}
0 0
- IP的int型与char*型相互转化
- char与int型的相互转换
- int型与char型的转化
- int、char、String之间的相互转化
- int 型数组与vector对象之间的相互转化
- 如何实现int与CString,char*与CString,float与CString之间的相互转化
- int与CString,char*与CString,float与CString之间的相互转化
- int与CString,char*与CString,float与CString之间的相互转化
- int型和char型数据 以及int 与string的相互转换
- char与int转化
- char* 与 WCHAR* 的相互转化
- TCHAR 与CHAR的相互转化
- string与unsigned char*的相互转化
- char *与NSString*的相互转化
- char str[] 与 int的转化
- QString string int double char* 相互转化
- 有关int,float,double型与字符串char*类型的相互转换
- int型整数和BCD码之间的相互转化
- ActivityGroup返回键获取焦点处理
- POJ 3974 Palindrome(最大回文串长度 Manacher算法)
- Struts2 OGNL投影功能案例
- 江苏电信欢go与省公安厅合作保无线上网安全
- Makefile的常见错误信息
- IP的int型与char*型相互转化
- linux中查找对应结构或者变量
- Migo收货增强
- 最新百度地图支持Fragment(注意事项)
- F5内网负载均衡配置--源地址保持影响
- path sum
- LeetCode题解:Invert Binary Tree
- 使用 spice-guest-tools 让虚拟机支持spicec 双屏显示
- 获取当前时间戳和随机数的获取