#include<iostream>
using namespace std;
/*
int main() {
int *p;
p = new int;
if (p==NULL)
{
cout << "Allocation Failure!\n";
}
else
{
*p = 15;
cout << *p;
delete p;
}
return 0;
}
*/
/*
int main() {
int *p;
p = new int(100);//分配空间的同时把值穿进去
if (p == NULL)
{
cout << "Allocation Failure!\n";
}
else
{
cout << *p;
delete p;
}
return 0;
}*/
//动态分配一维数组的存储空间
int main() {
int *p;
p = new int[100];//分配空间的同时把值穿进去
if (p == NULL)
{
cout << "Allocation Failure!\n";
}
else
{
for (int i = 0; i < 100; i++)
{
p[i] = i+1;
//p++;
}
for (int i = 0; i < 100; i++)
{
printf("%d ", p[i]);
//p++;
}
delete []p;
}
return 0;
}