1.c++利用指针创建数组
1.1一维数组的创建
void main1()
{
int *p = new int[10]; //一维数组的创建
for (int i = 0;i < 10;i++)
{
p[i] = i;
cout << p[i] << endl;
}
delete []p;
cout << p << endl;
system("pause");
}
1.2二维数组的创建
void main()
{
int(*p) = new int[80]; //二维数组的创建8行10列
int(*px)[10] = (int(*)[10])p;
int data = 0;
for (int i = 0;i < 8;i++)
{
for (int j = 0;j < 10;j++)
{
px[i][j] = data++;
cout << px[i][j]<<" ";
}
cout << endl;
}
delete []p;
}