string ip = "192.168.0.1";
int i = ip.find_last_of(".");
string sub = ip.substr(i+1, sizeof(ip) - i);
cout << sub<<endl;
//string to int
int tmp = strtol(sub.c_str(), NULL,10)+250;
cout << tmp<< endl;
//int to string
sub = to_string(tmp);
//cout << typeid(sub).name() << endl;
cout << sub << endl;
ip = ip.replace(i+1, sizeof(ip) - i, sub);
cout << ip << endl;
网友评论