IP 点分四段
2015-09-06 19:18
204 查看
#include <iostream> #include <cstring> using namespace std; char * my_strtok(char *p, const char *str) { static char *temp; int i=0; static int bit; if(p!=NULL) temp = p; else temp += bit+1; while(*(temp+i)!=*str && *(temp+i)!='\0') { i++; } if(*temp=='\0') { temp = NULL; } bit = i; if(temp!=NULL) *(temp+i) = 0; return temp; } int main() { char str[30] = {0}; char ptr[30] = {0}; cout << "input str: " ; cin >> str; cout << "input ptr: "; cin >> ptr; cout << "str: " << str << endl; cout << "ptr: " << ptr << endl; char *p = strtok(str, "."); cout << "first p: " << p << endl; while((p=(strtok(NULL, "."))) != NULL) { cout << p << endl; } char *q = my_strtok(ptr, "."); cout << "first q: " << q << endl; while((q=(my_strtok(NULL, "."))) != NULL) { cout << q << endl; } return 0; }
相关文章推荐
- 一起了解一下 UITextView 的使用
- 平衡查找树之2-3树
- MJrefresh
- BestCoder Round #54 (div.2)(hdu5427,hdu5428,hdu5429,hdu5430)
- SAE云应用Counter工具实现访问计数
- HDU 5429-Geometric Progression(JAVA大数判断等比数列)
- Android资源文件中保存字符串数组详解
- 文件上传
- Xenu-死链接检测工具
- JavaSwing基本控件汇总
- 纽曼欲借“机”上位,纽扣获YunOS力挺
- 牛客网C++错题本
- 三取方格数
- Swift Running
- mysql 报错
- spring mvc注解文件上传下载
- JAVA学习——多线程通信
- 移动互联网终端的touch事件判断方向
- 求水仙花数的
- hdu 3549 a flow problem 的多种解法