string到int的转换

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

#include 
bool str_to_uint64(const char* nptr, uint64_t& result) {
    char** endptr = '\0';
    result = strtoull(nptr, endptr, 0);
    if (endptr != '\0') {
        return false;
    }
    std::stringstream ss("");
    ss << result;
    std::string tmp = ss.str();
    if (tmp.compare(nptr) != 0) {
        return false;
    }
    return true;
}

 

转载于:https://my.oschina.net/u/347414/blog/2209693

你可能感兴趣的:(string到int的转换)