with updated information, the code below should do the trick.
#include <iostream> #include <string> #include <algorithm> #include <cstdlib> int main(void) { std::string base("7.8.9.1.5.1."); std::string check("7.8.9.1.5.1.100"); if (std::equal(base.begin(), base.end(), check.begin()) && check.find('.', base.size()) == std::string::npos) { std::cout << "val:" << std::atoi(check.c_str() + base.size()) << std::endl; } return 0; }
EDIT: updated to skip cases where there are more points left after the match, atoi would still analyze and return the value to . .
Nim
source share