输出ip最后一个点之后的数字
2015-12-16 11:43
260 查看
#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <WinSock.h>
#include <fstream>
//#pragma comment(lib,"ws2_32.lib")
using namespace std;
//bool sort(char * num,int totalNum);
void _tmain(int argc, _TCHAR* argv[])
{
string IP1="172.16.26.29";
string IP2="172.16.26.169";
string IP3="172.16.223.23";
string ss0=IP1.substr(IP1.find_last_of('.')+1,3);
string ss1=IP2.substr(IP2.find_last_of('.')+1,3);
string ss2=IP3.substr(IP3.find_last_of('.')+1,3);
string ss3=IP2.substr(IP2.find_last_of('.')+1); //当不给定第二个参数的时候,默认输出到末尾
cout<<ss0<<endl;
cout<<ss1<<endl;
cout<<ss2<<endl;
cout<<ss3<<endl;
}
输出:29
169
23
169
#include <iostream>
#include <ctime>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <WinSock.h>
#include <fstream>
//#pragma comment(lib,"ws2_32.lib")
using namespace std;
//bool sort(char * num,int totalNum);
void _tmain(int argc, _TCHAR* argv[])
{
string IP1="172.16.26.29";
string IP2="172.16.26.169";
string IP3="172.16.223.23";
string ss0=IP1.substr(IP1.find_last_of('.')+1,3);
string ss1=IP2.substr(IP2.find_last_of('.')+1,3);
string ss2=IP3.substr(IP3.find_last_of('.')+1,3);
string ss3=IP2.substr(IP2.find_last_of('.')+1); //当不给定第二个参数的时候,默认输出到末尾
cout<<ss0<<endl;
cout<<ss1<<endl;
cout<<ss2<<endl;
cout<<ss3<<endl;
}
输出:29
169
23
169
相关文章推荐
- iOS开发~视图(UIView)与控件(UIControl)
- 解决js提交过长问题
- JQuery获取radio中值的办法
- 树莓派 st-link master使用ST-LINK V2下载STM32程序 支持F0 F1 F2 等
- Android编程中出现The connection to adb is down问题的解决方法
- 多线程的自动管理各类锁的不同 线程池例子
- android 设置边框只显示部分线条
- 算法【6】:堆排序
- VB6.0 获取Excel文件工作表Sheet的名称
- Ubuntu设置时区和更新时间
- AD14使用积累
- UIPageViewController-浅析
- SpringMVC-Mybatis学习总结整理(上)
- C#基础——数据库连接字符串及数据库访问
- input输入框清除样式
- HTML/CSS中有序<ol&g bfb7 t;、无序<ul>、定义列表用法详解
- OC中的可变字典
- 持久化存储解决方案MagicalRecord使用入门
- 基于 CoreText 的排版引擎:进阶
- 查看ORC锁