std::stoi() problem.

Following advice from one of my other problems, I decided to make use of stoi(). Here is my implementation:

1
2
3
4
5
6
7
8
9
10
     //A sort of loading function
     char array[100];
     string medium;
     int health;

     ifstream saveFile ("Save.txt");

     saveFile.getLine(array, 100);
     medium = array;
     health = stoi(medium, NULL, 10);


Compiler(GNU GCC with Code::Blocks, latest version) tells me that stoi() was not declared in this scope. When I replace stoi with std::stoi, despite the fact that I included using namespace std; at the beginning of the program. All necessary libraries, iostream and string, are included. I have no idea what is going on, please help!

Thank you in advance!
std::stoi is part of C++11, make sure your compiler is compliant with this version of the standard and that you use the proper compilation flag
I am using the proper flag, how do I check for compliance?
Given that you're using C strings, you could use atoi instead:

http://www.cplusplus.com/reference/cstdlib/atoi/

Otherwise, if you're using a 32-bit version of MinGW, then you don't have stoi (or any of those other std::string <--> integer conversion functions, for that matter).

http://www.cplusplus.com/forum/beginner/120836/
Damn. How come string - integer conversions are not included in 32-bit MinGW? Isn't it all the same language?
But thank you for the solution, anyway!
Topic archived. No new replies allowed.