Allocating Array In C++
If
we want any allocating array for dynamic
memory allocate which we needed so for this we have to use new keyword or if we
want to memory allocation to delete so we needed to use delete keyword.
Program:
#include<iostream.h>
#include<conio.h>
void
main()
{
int
*p;
p=new
int[5];
cout<<”example
of allocating object”;
for(int
i=0,i<=4;i++)
{
cin>>p[i];
for(int
j=0;j<=4;j++)
{
cout<<”p[j];
}
}
delete p;
getch();
}
Output:
Allocating array
3
4
5
6
7
34567
No comments:
Post a Comment