C++ 2d char array to string

hope this piece of code will help, welcome to c++

#include <iostream>
using namespace std;
int main()
{
   char foo[3][3] = {{'a','b','c'}, {'d','e','f'},{'g','h','i'}};
   string bar;
   bar = "";
   for(int i =0 ; i< 3;i++)
   {
      for(int j =0 ;j<3;j++)
      {
          bar += foo[i][j];
      }
   }
   cout<< bar; //abcdefghi

 return 0;
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)