I'm new to C++ and I have some problem with memory allocation.
vector<int *> V;
for(int i=0;i<3;i++){
int A[3];
cin>>A[0]>>A[1]>>A[2];
V.push_back(A);
}
for(int i=0;i<3;i++){
cout<<V[i][0]<<V[i][1]<<V[i][2]<<endl;
}
I want to create arrays and push them into vector as below. But if I input
1 1 1
2 2 2
3 3 3
The output will be
3 3 3
3 3 3
3 3 3
If I replace int A[3] with int *A=new int() then I get the right answer. I want to know why?