I have a problem with passing an array to a function and then modifying it. For example:
void foo(int ** a) {
int * b = new int[3]
//Initialize b, i.e b = {3, 2, 1}
a = &b;
//*a = {3, 2, 1}
}
int * c = new int[3]
//Initialize c; c = {1, 2, 3}
foo(&c);
// c is still {1, 2, 3}. Why?
I'm not really sure why c
doesn't point to the same array as b
.