#include<iostream>
using namespace std;
void seed(int* matrixAddr, int n, int m);
void main()
{
int n, m;
cin >> n >> m;
int matrix[n][m]; // DevC++ does not throw an error here, where VS does instead
seed(matrix, n, m);
}
void seed(int* matrixAddr, int n, int m) {}
Accessing matrix
directly means referencing a memory address - in this case, to the first element of the two-dimensional array.
Apparently, though, the address cannot be passed as-is to the seed
function, which accepts a pointer as its first argument.
Why does this happen? Should this not be allowed?
The error DevC++ throws is the following: [Error] cannot convert 'int (*)[m]' to 'int*' for argument '1' to 'void seed(int*, int, int)'