Below is a program which i wrote i want to make a dynamic array,my program is getting input.it should output the integers which i have entered but the program is displaying the addresses of the the input integers....
#include "stdafx.h"
#include <iostream>
using namespace std;
void main()
{
int *p=NULL;
int n;
cout<<"Enter the size of the array";
cin>>n;
p=new int[n];
cout<<"Enter the elements of the array";
for(int i=0;i<n;i++)
cin>>*p++;
cout<<"Entered elements in the array are:";
for(int i=0;i<n;i++)
cout<<p++<<endl;
system("pause");
}
Change your last cout statement to *p++. Without the *, you're using the memory location of p, or rather, what p points to. You did it right in the step above.