title: C++ std::out_of_range error when I try to run the program
body: <p>Okay so first off, Im pretty new to programming, Ive only read a bit of stuff and have been working on some project Euler problems to kind of wrap my head around concepts and such. However, I got an error message today that I couldn't make any sense of so I thought I would ask here for some help! Any links or advice is appreciated!</p>
  
  <p>Here's the error message:</p>
  
  <pre><code>terminate called after throwing an instance of 'std::out_of_range'  
  what(): basic_string::substr Aborted
  </code></pre>
  
  <p>So any advice you might have would be awesome! If you need to see my code or have questions, ask! Though I''d rather try to understand the problem then find the answer myself! Thanks!</p>
  
  <p>EDIT: Okay since you guys say you would need to see the code here it is.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  using namespace std;
  
  int stringtoint(string s_convertee)
  {
      int i=0;
      istringstream sin(s_convertee);
      sin &gt;&gt; i;
      return i;
  }
  
  
  int main()
  {
  string s_testnum = "233456091289474545356";
  int n_maxmult = 0;
  for (int i = 0; i&lt;s_testnum.length(); i++)
    {
        int n_product = 1;
        for (int j = i; j&lt;(i+4); j++)
        {
            string s_multiplier = s_testnum.substr(j, 1);
            int n_multiplier = stringtoint(s_multiplier);
            n_product *= n_multiplier;
        }
        if (n_product&gt;n_maxmult)
        {
            n_maxmult = n_product;
        }
  
    }
  return 0;
  }
  </code></pre>