c - Using malloc for allocation of multi-dimensional arrays with ... First, you need to allocate array of pointers like c = ( char** )malloc( N*sizeof( char* )) ... then replace M with the appropriate length for that element; for example