I'm trying to get the point for the array to return the value I enter, but it returns the memory location not the value. I tried using *y[2], but that gave me an error.
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter the number of elements:"<<endl;
cin >> n;
#include <iostream>
usingnamespace std;
int main()
{
int n;
cout << "Enter the number of elements:"<<endl;
cin >> n;
int x[n];
int *y;
y = x;
cin >> x[n];
cout << "hope this works " << y[2];
return 0;
}
you are not using the pointer for dynamic memory.
1 2 3 4
int *array = newint [size];
cout << "enter the size of the array. ";
cin >> size;