title: C++ 2d char array to string
body: <p>How can you convert a 2d char array into a string?</p>
  
  <pre><code> int main()
  {
     char foo[3][3] = {{'a','b','c'}, {'d','e','f'},{'g','h','i'}};
     string bar;
     bar = foo;
     cout&lt;&lt; bar; //abcdefghi
  
   return 0;
  }
  </code></pre>
  
  <p>also can you convert only select parts of a 2d array to a string?</p>
  
  <pre><code> int main()
  {
     char foo[3][3] = {{'a','b','c'}, {'d','e','f'},{'g','h','i'}};
     string bar;
     bar = foo[0][1] + foo[1][2] + foo[2][0];
     cout&lt;&lt; bar; //bfg (bar contains only b, f, and g)
  
   return 0;
  }
  </code></pre>