How to fix C++ error: 'stoi' is not a member of 'std'
Problem
When compiling C++ code, you may encounter the following error message:
/home/uli/myproject/main.cpp:162:26: error: 'stoi' is not a member of 'std'
162 | g = std::stoi(argv[3])
Solution
You need to include the <string>
header in your C++ code.
The stoi
function is part of the C++ standard library and is defined in the <string>
header.
Add this line at the top of your C++ file:
#include <string>
After that, try to compile your code again. The error should be resolved.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow