title: infinite loop on printing 2D array
body: <pre><code>#include &lt;stdio.h&gt;
  
  
  void main()
  {
      char plaintext[50];
      char key[20];
      int plain=0,max1=0,max2=0; // max2 amount of coloumn n max1 for row on chip
      char chip[30][30];
      int i,j,k=0,c=0;
  
      printf("Enter key :");
      scanf("%s",&amp;key);
  
      for(i=0;key[i]!='\0';i++)
      {
          max2++; 
      }
  
      printf("Enter plaintext :");
      scanf("%s",&amp;plaintext);
  
      for( i = 0; plaintext[i] != '\0'; i++ ) 
      {
          plain++; 
      }
      if (plain%max2==0)
      max1=plain/max2;
      else
      max1=plain/max2+1;
      while(plaintext[k]!='\0')
      {
  
          for (i=0;i&lt;max1;i++)
          {
              for (j=0;j&lt;max2;j++)
              {
              chip[i][j]=plaintext[k];
              k++;
              }
          }
      }
      printf("%s",chip[0][0]);
  }
  </code></pre>
  
  <p>1st im trying to move the string on plain (1D array) into chip(2d array) with dynamic array on the 2D but when im trying to run this code it show nothing than stopped working.. is there anything goes wrong with my 2D array?</p>