Q:

C++ std::out_of_range error when I try to run the program

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!
Here's the error message:
terminate called after throwing an instance of 'std::out_of_range'  
what(): basic_string::substr Aborted

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!
EDIT: Okay since you guys say you would need to see the code here it is.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int stringtoint(string s_convertee)
{
    int i=0;
    istringstream sin(s_convertee);
    sin >> i;
    return i;
}

int main()
{
string s_testnum = "233456091289474545356";
int n_maxmult = 0;
for (int i = 0; i<s_testnum.length(); i++)
  {
      int n_product = 1;
      for (int j = i; j<(i+4); j++)
      {
          string s_multiplier = s_testnum.substr(j, 1);
          int n_multiplier = stringtoint(s_multiplier);
          n_product *= n_multiplier;
      }
      if (n_product>n_maxmult)
      {
          n_maxmult = n_product;
      }

  }
return 0;
}

A:

From C++ Reference for substr,

If the position passed is past the end
  of the string, an out_of_range
  exception is thrown.

So my guess would be your calling substr with a first parameter that's greater than the strings length.

Since you've posted your code, you can see, 
i can be a maximum of s_testnum.length()-1, 
but 
j goes up to i+4-1 = s_testnum.length()+2. 
You then call substr with a first parameter of j which as said can be longer than the string length. So there's the problem.

A:

As other answers have already pointed out, in substr
If the position passed is past the end of the string, an out_of_range exception is thrown.
In your code:
for (int j = i; j<(i+4); j++)

When i is 1 less than s_testnum.length() j goes past s_testnum.length() and when you do, s_testnum.substr(j, 1); causes an out_of_range exception.

A:

Please post your code in question. Chances are you did something like:
std::string s("foo");
s.substr(5, 1); // The length of the string is 3, 5 is out of bounds

