C++ 中如何动态创建数组?

2024-11-17 14:54:54
推荐回答(1个)
回答1:

有动态的和静态的
new/delete
malloc/free

例如:
分配内存
int **a = new int* [lenth];
for(int i = 0; i < lenth; ++i)
a[i] = new int [lenth];

释掘或改放判判内存:团返
for(int i = 0; i < lenth; ++i)
delete []a[i];
delete []a;