I need to do this to persist operations on the matrix as well. Does that mean that it needs to be passed by reference?
Will this suffice?
void operate
#include
using namespace std;
void printarray(int *a, int c,int r)
{
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
cout << "\t" << *(a + i*c + j) << "\t"; // a is a pointer refer to a 2D array
}
cout << endl << "\n\n";
}
}
int main()
{
int array[4][4] =
{{1 ,2 ,3 ,4 },
{12,13,14,5 },
{11,16,15,6 },
{10,9 ,8 ,7 }};
printarray((int*)array,4,4);
// here I use print function but u can use any other useful function like
//setArray((int *) array,4,4);
return 0;
}