title: How to convert a 2D array into a single string in c++
body: <p>Am writing a pathfinder and have a 21x21 array which I want to convert into a single string. The array will contain only 1's and 0's. The 1's are placed together in order to form the path.</p>
  
  <p>My current relevant code snippet is </p>
  
  <pre><code>std::string str;
  
  for(int i = 0; i &lt; 21; i++)
  {
      for(int j = 0; j &lt; 21; j++)
      {
          str += grid[i][j];
      }
  }
  
  std::cout &lt;&lt; str;
  return (str);
  </code></pre>
  
  <p>When I run the code it jumps to a file containing
  <code>static inline size_t length(const char_type* __s) {return strlen(__s);}</code> and says <code>EXC_BAD_ACCESS</code>.</p>