title: Segmentation fault (core dump) - for loop with multidimensional vector C++98
body: <p>I am getting a segmentation fault (core dumped) error when I try to run this program on Ubuntu 14.04 terminal. It got compiled correctly but when I run the program it gives me a segmentation fault (core dumped). I know the problem is with the nested for loop block right there because when I remove that part,</p>
  
  <pre><code>for(int i = 0; i &lt; 500; i++){
     for(int j = 0; j &lt; 500; j++){
       map[i][j] = "unknown";
     } 
   }
  </code></pre>
  
  <p>the program works just fine, but if I include the block of code above it doesn't. Below is the whole program in progress:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;vector&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  int moves = 0;
  string input;
  vector&lt; vector&lt;string&gt; &gt; map;
  
  int main(int argc, char **argv) {
  
   for(int i = 0; i&lt; 500; i++){
     for(int j = 0; j&lt; 500; j++){
     map[i][j] = "unknown";
     } 
   }
  
    while ( 1 ) {
      getline(cin, input); 
      cout &lt;&lt; "#"&lt;&lt; input[0] &lt;&lt; endl; 
      cout &lt;&lt; "#"&lt;&lt; input[2] &lt;&lt; endl;
      cout &lt;&lt; "#"&lt;&lt; input[4] &lt;&lt; endl;
      cout &lt;&lt; "#"&lt;&lt; input[6] &lt;&lt; endl;
      cout &lt;&lt; "#"&lt;&lt; input[8] &lt;&lt; endl;
  
      cout &lt;&lt; "forward" &lt;&lt; endl;
  
    }
  
    for(int i = 0; i&lt; map.size(); i++){
      for (int j = 0; j &lt; map.size(); j++){
        cout &lt;&lt; "#" &lt;&lt; map[i][i] &lt;&lt; endl;
      }
    }
    return 0;
  }
  </code></pre>
  
  <p>Any expert out there who can help identify the problem?</p>