From 722d8eb479f1ee8027eb521b184dadef9f5b4881 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 7 Nov 2022 07:49:40 +0800 Subject: [PATCH] chore(judger): use `stoi()` to convert string to int --- judger/uoj_judger/include/uoj_judger.h | 4 ++-- judger/uoj_judger/include/uoj_judger_v2.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/judger/uoj_judger/include/uoj_judger.h b/judger/uoj_judger/include/uoj_judger.h index d449242..0dda40c 100644 --- a/judger/uoj_judger/include/uoj_judger.h +++ b/judger/uoj_judger/include/uoj_judger.h @@ -620,7 +620,7 @@ int conf_int(const string &key, const int &val) { if (config.count(key) == 0) { return val; } - return atoi(config[key].c_str()); + return stoi(config[key]); } int conf_int(const string &key, int num, const int &val) { ostringstream sout; @@ -628,7 +628,7 @@ int conf_int(const string &key, int num, const int &val) { if (config.count(sout.str()) == 0) { return conf_int(key, val); } - return atoi(config[sout.str()].c_str()); + return stoi(config[sout.str()]); } int conf_int(const string &key) { return conf_int(key, 0); diff --git a/judger/uoj_judger/include/uoj_judger_v2.h b/judger/uoj_judger/include/uoj_judger_v2.h index e8f1598..c6277f5 100644 --- a/judger/uoj_judger/include/uoj_judger_v2.h +++ b/judger/uoj_judger/include/uoj_judger_v2.h @@ -488,7 +488,7 @@ int conf_int(const string &key, const int &val) { if (uconfig.count(key) == 0) { return val; } - return atoi(uconfig[key].c_str()); + return stoi(uconfig[key]); } int conf_int(const string &key, int num, const int &val) { ostringstream sout; @@ -496,7 +496,7 @@ int conf_int(const string &key, int num, const int &val) { if (uconfig.count(sout.str()) == 0) { return conf_int(key, val); } - return atoi(uconfig[sout.str()].c_str()); + return stoi(uconfig[sout.str()]); } int conf_int(const string &key) { return conf_int(key, 0);