title: C++ - stoi() was not declared in this scope
body: <p>I'm practicing my C++ by coding simple input/ouput from user. I have now been searching for over an hour on how to convert a string to an int. Every answer is different, and require something else.</p>
  
  <p>I'm using Code::Blocks v.13.12. MingW32 folder is added to environment variables. I ended up using stoi to convert my string to integer with try/catch block. I've added C++11 support in Code::Blocks by going to <code>Settings -&gt; Compiler</code> and tick <code>Have g++ follow the C++11 ISO language standard [-std=c++11]</code>. <strong>It compiles and runs fine in CB</strong>, but when I'm trying to compile manually in the command line i get this error:</p>
  
  <p><code>error: 'stoi' was not declared in this scope</code>. The line it is refering to: <code>characters = stoi(input);</code></p>
  
  <p>Thise are the commands I've tried so far:
  <code>g++ -std=c++11 main.cpp</code> &amp; <code>g++ -std=c++11 -c main.cpp -o main.o</code> &amp; <code>mingw32-g++ -std=c+11 -c main.cpp -o main.o</code> (which is what CB is using according to the output log)</p>
  
  <p>If you have e better example than <code>stoi()</code>, please do make it simple, and add full text of try/catch.</p>
  
  <p><strong>EDIT</strong>: This is written at the top of my file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include &lt;string&gt;
  #include &lt;algorithm&gt;
  #include &lt;stdexcept&gt;
  using namespace std;
  </code></pre>
  
  <p>Error message refers to:</p>
  
  <pre><code>int player;
  string input;
  
  cin &gt;&gt; input;
  player = stoi(input)
  </code></pre>
  
  <p>My Code::Blocks compiler outputs this log:</p>
  
  <pre><code>mingw32-g++.exe -std=c++11  -c "C:\Users\&lt;name&gt;\#C++\main.cpp" -o "C:\Users
  &lt;name&gt;\#C++\main.o"
  mingw32-g++.exe  -o "C:\Users\&lt;name&gt;\#C++\main.exe" "C:\Users
  &lt;name&gt;\#C++\main.o"   
  Process terminated with status 0 (0 minute(s), 0 second(s))
  0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
  </code></pre>
  
  <p>Source code, as requested: <em>removed as it is not related to the solution</em>.</p>