Whenever I try using the function stoi() , I get the error “ Use of undeclared identifier ’stoi’ “. So, is it something I have to include in my code or what?
Asked
Active
Viewed 230 times
-3
-
Answer: Yes, but that has nothing to do with CLion. BTW: Please take the [tour] and read [ask]. – Ulrich Eckhardt Aug 29 '20 at 16:06
-
Did you mean `atoi` ?? – Majid Hajibaba Aug 29 '20 at 16:08
-
1You need to include
. @majidhajibaba atoi is the old C function; See [this](https://stackoverflow.com/questions/20583945/what-is-the-difference-between-stdatoi-and-stdstoi) for more details. – SuperStormer Aug 29 '20 at 18:07
1 Answers
3
To use the std::stoi function you need to #include <string>
.
If you don't include the header declaring the function you use, the compiler has no idea what you are trying to call.
This has nothing to do with your IDE btw (CLion or something else). That's just basic C++. Include what you use.

Jesper Juhl
- 30,449
- 3
- 47
- 70