title: Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) in Xcode Error
body: <p>I am writing some code that solves a crossword puzzle in the form of a text file. Parsing the file and creating the crossword of type <code>vector&lt;vector&lt;char&gt;&gt;</code> works correctly. I am encountering a <code>EXC_BAD_ACCESS (code=EXC_I386_GPFLT)</code> error in the <code>horizontal_forward_search</code> function, upon indexing the crossword, <code>crossword[row_num][col_num]</code>.  </p>
  
  <pre><code>pair&lt;int, int&gt; iterate(vector&lt;vector&lt;char&gt;&gt; crossword, string word) {
      int row_num = 0;
  
      for (vector&lt;char&gt; row: crossword) {
          ++row_num;
          int col_num = 0;
          for (char letter: row) {
              ++col_num;
              if (letter == word[0]) {  // first letter of word found, confirm/deny word
                  pair&lt;int, int&gt; location = horizontal_forward_search(crossword, row_num, col_num, word);
                  if (location.first != -1)
                      return location;
  
              }
          }
      }
      return make_pair(-1, -1);
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>pair&lt;int, int&gt; horizontal_forward_search(vector&lt;vector&lt;char&gt;&gt; crossword, int row_num, int col_num, string word) {
      long remaining_chars = crossword[row_num].size() - col_num;
  
      if (word.size() &gt; remaining_chars)   // word size exceeds remaining characters
          return make_pair(-1, -1);
  
      else {
          string temp_str = "";
          int cur_pos = col_num;
          int i = 0;
          while (i &lt; word.size()) {
              char cur_letter = crossword[row_num][col_num];  // Error here
              temp_str.push_back(cur_letter);
              ++cur_pos;  // next pos in array
              ++i;
          }
          if (temp_str == word)
              return make_pair(row_num, col_num);
      }
      return make_pair(-1,-1);
  
  }
  </code></pre>
  
  <p>I know there are several ways to debug this instrumentally, but the code is straight forward. In the <code>iterate</code> function, <code>crossword</code> is copied over to <code>crossword</code> within the <code>horizontal_forward_search</code> function, ideally giving access to the crossword. Yet, upon doing <code>crossword[row_num][col_num]</code>, I am met with an error. </p>