string到int的转换

#include <sstream>
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;
}
相关文章
相关标签/搜索