I was creating a function that would give me random values of a matrix. I know how to make it in the main
function but I want a separate one. I also tried with void
and the same thing happened, and I keep getting the same error. I am beginner and I understand that the issue is something to do with pointers but I still don't know what should I do to make it work and fix it. I already Googled it but I can't make this work.
#include<stdlib.h>
#include<iostream>
#include<time.h>
int row, coll;
int random(int *mat[])
{
srand(time(0));
for(int i=0; i<row; i++)
{
for(int j=0; j<coll; j++)
{
mat[i][j] = rand()%10;
}
}
}
main()
{
std::cin >> row >> coll;
int mat[row][coll];
random(mat);
}