title: How to put the values of a 1D array into a 2D array in C++ using for loop
body: <p>I want to put the values for a 1 D array into a 2D array. Then I want to print out the values of the 2D array.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;conio.h&gt;          //for _kbhit
  using namespace std;
  #define MAX_N 100
  
  #include&lt;stdio.h&gt;
  
  int c[MAX_N] = {35, 23 , 56 , 30, 110 , 123 , 13 , 31 };
  
  int b[4][4];
  int main()
  {
  
      int i,j,k,l;
      for(i=0;i&lt;8;i++)
      { cout &lt;&lt; c[i];}
      cout &lt;&lt; endl;
  
      for(i=0;i&lt;4;i++)
      {   for(j=0;j&lt;4;j++)
           {
            b[i][j] = c[i];
           }
      }
      for(i=0;i&lt;4;i++)
          {
              for(j=0;j&lt;4;j++)
                  {
                      cout &lt;&lt; b[i][j] &lt;&lt; " ";
                  }
          cout &lt;&lt; "\n";   
          cout &lt;&lt; "\n";
          }
  cout &lt;&lt; "\n\nHit&lt;enter&gt; to finish";
  while ( !_kbhit());
  return (0);
  }
  </code></pre>
  
  <p>The output should be:</p>
  
  <pre><code>35 23 56 30
  110 123 13 31 
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Thanks!</p>