title: Take a digit of a string as an integer in C++
body: <p>I want to add the first digit of a string <code>111</code> to the integer <code>x = 0</code> so that it equals</p>
  
  <p><code>x = 0 + 1 = 1</code></p>
  
  <p>The following code takes the character <code>1</code> instead of the integer <code>1</code>:</p>
  
  <pre><code>int x = 0;
  string str = "111";
  x += str[1];
  </code></pre>
  
  <p><code>std::stoi</code> did not work either:</p>
  
  <p><code>x += std::stoi(str[1]);</code></p>