can i pass a multi-dimension array without passing its size using pointers?
#include <iostream>
using namespace std;
void PrintArray( int(*pInt)[3] )
{
// how to iterate here printing pInt content?
int nRow = sizeof(*pInt) / sizeof(int);
cout << nRow << endl; // the result: 3 not 2! i get the nColumns instead!!?
}
int main()
{
int array[2][3] = { {1,2,3},
{4,5,6}};
int(*pArray)[3] = array;
PrintArray(pArray);
return 0;
}
- can anyone add the correct definition of PrintArray to print its elements
- is there a way to pass arrays as a pointer and without passing the size?
- thank you for throwing a glance