Q:

Passing matrix to a function

I am getting an error when calling the 'printMat' function.  My requirement is to create a matrix after accepting the number of rows and columns, and then take input into the matrix, then call the printMat by sending the matrix and print the elements.  The error is as follows:
error: parameter 'a' includes pointer to array of unknown bo
und 'int []'
#include<iostream>
using namespace std;

int row,col;

void printMat(int* a[])
{
    for(int i=0; i<row; ++i)
    {
        for(int j=0; j<col; ++j)
        {
            cout<<a[i][j]<<" ";
        }
    }
}

int main()
{   
    cin>>row;
    cin>>col;

    int mat[row][col];

    for(int i=0; i<row; ++i)
    {
        for(int j=0; j<col; ++j)
        {
            cin>>mat[i][j];
        }
    }

    printMat(mat);

    return 0;
}

A:

int* a[]

is an array of pointer, but you are passing a pointer to an array:
int (*a)[]

