int main()
{
int *p , temp ;
p = new int [5];
temp = p;
for ( int i = 0 l i < 5; i ++)
{
*p = i ;
p ++;
}
p = temp ;
for ( int i = 0; i < 5; i ++)
{
cout << p [ i ];
{
delete p [];
int q [5];
q [0]=0;
q ++;
return 0;
}
And this is a classic reason to declare variables one per line, and wait until there is a value to initialise with:
1 2
int* p = newint [5];
int* temp = p;
Is there a reason why you wish to use new and delete ? They are not recommended. Consider using a STL container like std::vector instead. Most of the STL containers store their data on the heap.