Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何为以下多维数组分配内存?
char* array[NMAX];
#define NMAX 50 char* array[NMAX];
是一个由 50 个字符指针组成的数组。
您必须遍历所有这些并为每个分配内存。
for( int i = 0 ; i < NMAX ; i++ ) { array[ i ] = malloc( sizeof( char ) * 80 ) ; }