I would like to modify my array (multiplying by 2 each of its elements) using pointers, but I do not know why my code is not working ...
#include<stdio.h>
void changematrix(int **mm,int row, int column)
{
int i,j;
for( i = 0;i < row; i++)
{
for( j = 0; j < column; j++)
{
*(*(mm + i) + j) = 2* *(*(mm + i) + j);
}
}
}
int main()
{
int i,j;
int row, column;
printf("Type the number of row\n");
scanf("%d", &row);
printf("Type the number of columns\n");
scanf("%d",&column);
int mat[row][column];
printf("Now type the numbers\n");
for( i = 0; i < row; i++)
{
for( j = 0; j < column; j++)
{
scanf("%d", &mat[i][j]);
}
}
changematrix(&mat,row,column);
for( i = 0; i < row; i++)
{
for( j = 0; j < column; j++)
{
printf("%d ",mat[i][j]);
}
printf("\n");
}
}