#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