Hello Dear Community,
I'm working with c++ arrays (static and dynamic ones). My static array A1 has a [30][30] size and my dynamic array A2 is [30*30] long.
What I want to do is to copy A1 into A2.
The content of the arrays A1 & A2 is filled with random integer numbers between 0 and 9.
Here is my previous solution approach:(I think so far I made the copy into A2, but I can't figure out, how to return array A2. )
int main() {
//Array 2-Dimensional
int A1[30][30] = { 0 };
int *A2 = new int[30*30];
int x, j, z;
for (x = 0; x < 30; x++) {
for (j = 0; j < 30; j++) {
A1[x][j] = rand() % 10;
printf("%d ", A1[x][j]);
for (z = 0; z < 30 * 30; z++) {
A2[z] = A1[x][j];
}
}
printf("\n");
}
system("Pause");
return 0;
}