So i have an assigment that would read a matrix using pointers and show it using pointers also i wanna know why it always add a row where is exactly the mistake and it doesnt show the matrix also thnks
#include <iostream>
using namespace std;
int main ()
{
int Mat[50][50],N,M;
int (*ptr)[50][50];
cout<<"number of lignes : ";
cin>>N;
cout<<"number of rows : : ";
cin>>M;
ptr=&Mat;
for (int i=0;i<N;i++)
{
for (int j=0 ; j<M ;j++)
{
cout<<"fill the matrix [" <<i<<","<<j<< "] : " ;
cin>>*ptr[i][j];
}
}
for (int i=0 ; i<N ; i++ )
{
for (int j=0 ; j<M ; j++)
{
cout<<*ptr[i][j] <<" ";
}
cout<"/n";
}
return 0;
}
question from:https://stackoverflow.com/questions/65541016/matrix-using-pointers-c-without-dynamic-allocation