title: libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string Error?
body: <p>Here is a function I'm writing that receives a string of words separated by spaces and adds each word to an array. I keep getting an error that says "libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string." I can't seem to find what the error is.</p>
  
  <pre><code>void lineParser(string line, string words[])
  {
      string word = "";
      int array_index = 0;
      int number_of_words = 1;
      int string_index = 0;
      while (string_index &lt; line.length())
      {
          if (line.substr(string_index,1) != " ")
          {
              int j = string_index;
              while (line.substr(j,1) != " ")
              {
                  word += line.substr(j,1);
                  j++;
              }
              words[array_index] = word;
              array_index++;
              word = "";
              number_of_words++;
              string_index = j;
          }
          else
          {
              string_index++;
          }
      }
  }
  </code></pre>