i was trying to copy two dimensional array to another array with another size. For example: first array with 4 rows and 4 columns:
1 2 3 4
5 6 7 8
9 0 1 2
3 4 5 6
second array with 2 rows and 8 columns:
1 2 3 4 5 6 7 8
9 0 1 2 3 4 5 6
and if there are in the new array more elements than first one then the function will fill it with 0
this is the function i made, but the problem with indexes. How to write it in the right way?
void changearr(int **ppm, int size1, int size2, int size_1, int size_2)
{
int **temp = new int*[size_1];
for (int i = 0; i < size_1; i++)
temp[i] = new int[size_2];
int z = 0;
for (int i = 0; i < size_1; i++, z++)
{
for (int j = 0, k = 0; j < size_2; j++, k++)
{
if (i < size_1 || j < size_2)
{
temp[i][j] = ppm[z][k];
}
else
temp[i][j] = 0
}
}