title: In C++, are s[i] - '0' and atoi() same?
body: <p>Are <code>atoi()</code> and <code>s[i] - '0'</code> same?</p>
  <pre><code>int countSubstrings(string s, int n)
  {
      int count = 0, sum = 0;
  
      unordered_map&lt;int, int&gt; mp;
      mp[0]++;
  
      for (int i = 0; i &lt; n; ++i) {
  
          sum += (s[i] - '0');
            cout &lt;&lt; sum &lt;&lt; endl;
          count += mp[sum - (i + 1)];
          ++mp[sum - (i + 1)];
      }
      return count;
  </code></pre>
  <p>In the above code, can we use the <code>atoi()</code> function instead of using <code>s[i] - '0'</code>?</p>