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