c language two-dimensional array assignment

  int m = 2 , n-= 2 ; // number of rows and columns 
  pattern = ( char **) the malloc ( the sizeof ( char *) * m); // apply a set of one-dimensional space pointer. 

  for ( int I = 0 ; I <m; I ++ ) 

      pattern [I] = ( char *) the malloc ( the sizeof ( char ) * n-); // for each one-dimensional pointer, a line of data space applications. 

  for ( int I = 0 ; I <m; I ++) // assigned to each element 

      for ( int j = 0; j < n; j++)
      {
          pattern[i][j] = '0';
      }

 

Guess you like

Origin www.cnblogs.com/taoyuanming/p/11611288.html