Why is p[1].x printing out to a garbage value? Is it possible to initialize a dynamically allocated array to a given array? If yes, then how?
#include <ioStream>
using namespace std;
struct point{
int x;
int y;
};
int N;
point *p = new point[N];
int main(){
cin>>N;
for(int i=0; i<N; i++){
cin>>p[i].x>>p[i].y;
}
for(int i=0; i<N; i++){
cout<<"("<<p[i].x<<", "<<p[i].y<<")"<<endl;
}
}