title: Program received signal SIGSEGV, Segmentation fault. when using vector<string>
body: <p>Hey i wanted to make a program to solve a maze from file and to load the file in the program i used <code>vector&lt;string&gt;</code> and it's showing SIGSEGV, Segmentation fault.</p>
  
  <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  
  vector&lt;string&gt; labyrinth;
  bool visited[100][100];
  void printlav(vector&lt;string&gt; s)
      {
          for(int i = 0; i &lt; s.size(); i++)
      {
          for(int j = 0; j &lt; s.at(i).size(); j ++)
          {
              cout &lt;&lt; s[i][j];
          }
          cout &lt;&lt; "\n";
      }
  }
  vector&lt;string&gt; solve(vector&lt;string&gt; s,int x,int y)
  {
      printlav(s);
      if(s[x][y] == 'K')
      {
          return s;
      }
      if(s[x - 1][y] != '#' &amp;&amp; !visited[x - 1][y])
      {
          s[x - 1][y] = '+';
          visited[x - 1][y] = 1;
          s = solve(s, x - 1, y);
      }
      if(s[x + 1][y] != '#' &amp;&amp; !visited[x + 1][y])
      {
          s[x + 1][y] = '+';
          visited[x + 1][y] = 1;
          s = solve(s, x + 1, y);
      }
      if(s[x][y -1] != '#' &amp;&amp; !visited[x][y - 1])
      {
          s[x][y - 1] = '+';
          visited[x][y - 1] = 1;
          s = solve(s, x, y - 1);
      }
      if(s[x][y + 1] != '#' &amp;&amp; !visited[x][y + 1])
      {
          s[x][y + 1] = '+';
          visited[x][y + 1] = 1;
          s = solve(s, x, y + 1);
      }
  }
  int main()
  {
      string line;
      int row = 0, rs,ks;
      ifstream file_("write_here.txt");
      if(file_.is_open())
      {
          while(getline(file_, line))
          {
              labyrinth.push_back(line);
              for(int i = 0; i &lt; line.size(); i++)
              {
                  if(line[i] == 'P')
                  {
                      rs = row;
                      ks  = i;
                  }
              }
              row ++;
  
          }
          labyrinth = solve(labyrinth, rs, ks);
          for(int i = 0; i &lt; labyrinth.size(); i++)
          {
              for(int k = 0; k &lt; labyrinth[i].size(); k++)
              {
                  cout &lt;&lt; labyrinth[i][k];
              }
          }
          file_.close();
  
      }
      else
          cout &lt;&lt; "File isn't open";
  }
  </code></pre>