void* make_n_d_array( int n )
{
// suppose you want an n-d array like: int a[100][100][100]...
void** p = 0;
if (1 < n) {
p = (void**)malloc( 100 * sizeof( void* ));
for (int i = 0
i < 100
++i) {
p = make_n_d_array( n - 1);
}
}
else if (1 == n) {
p = (void**)malloc( 100 * sizeof( int ));
}
return p;
}
int main()
{
int*** array_3d;
array_3d = (int***)make_n_d_array( 3 );
array_3d[1][3][4] = 9;
}
数组长度也是动态的怎么办?
a hint: use <stdarg.h>, i.e. the '...'. left to you as an exercise ba...