Getting compilation error as Stack smashing detected. Even while printing a 2*2 array it is throwing me the same error. Kindly,check
below is my code*
#include
using namespace std;
void readMatrix(int a[][10],int M,int N)
{
for(int i=0;i < M; i++)
{
for(int j=0;j< N; j++)
{
cin>>a[i][j];
}
}
}
void printWave(int a[][10],int M, int N)
{
for(int j=0; j<N;j++)
{
if((j==0) || (j%2==0))
{
for(int i=0;i<M;i++)
{
cout<<a[i][j]<<",";
}
}
else if( j%2 !=0)
{
for(int i=M-1;i>=0;i--)
{
cout <<a[i][j]<<",";
}
}
}
}
void printMatrix(int a[][10],int M, int N)
{
for(int i=0;i<M;i++)
{
for(int j=0;j<N;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
}
int main() {
int M,N;
cin >> M >>N;
int a[][10]={0};
if((M>1 && M <10) && (N >1 && N<10))
{
readMatrix(a,M,N);
// printWave(a,M,N);
printMatrix(a,M,N);
}
return 0;
}