Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的问题很简单,但我似乎无法找到它。我想知道使用stoi. 我正在使用atoi,它适用于
stoi
atoi
#include <iostream> #include <string> #include <stdlib.h> using namespace std;
但是当我使用stoi. 谢谢
您需要#include <string>并使用理解 C++11 的编译器。最小的例子:
#include <string>
#include <string> #include <cassert> int main() { std::string example = "1234"; int i = std::stoi(example); assert(i == 1234); return 0; }
例如,使用 编译g++ -std=c++11。
g++ -std=c++11