动态分配一维数组的存储空间
作者:互联网
#include<iostream>
using namespace std;
/*
type *p
p = new type[num]
...
delete []p
*/
/*
分配100个整数空间,将1到100存储在这100个连续的空间里
*/
int main() {
int *p;
p = new int[100];
for (int i = 0; i < 100; i++)
{
p[i] = i + 1;
}
for (int i = 0; i < 100; i++)
{
cout << p[i] << " ";
}
delete []p;
return 0;
}
标签:int,动态分配,++,一维,new,100,type,存储空间,delete 来源: https://www.cnblogs.com/wang-xiao-shuai/p/16445643.html