i have a function that generates randomize numbers between 0 and 2,and i want to use pointers but anyway i could not executed it.
First i generate randomize number and then i want to print the multidimensional array to see what it has generated
i just want to assign randomized number to an array(with using pointers) and then print them using pointers again
int **RandomizedMatrix; //integer multidimensional array
int ***AdressOfMatrix = &RandomizedMatrix; //assigning the adress of matrix to an integer pointer
void RandomizedMatrixGenerator(int LineNumber,int ColumnNumber,int ***AdressOfMatrix)
{
int i,j;
for (i=0; i<LineNumber*ColumnNumber; i++)
{
**AdressOfMatrix = rand()%2;
}
for (i=0; i<LineNumber; i++)
{
for (j=0; j<ColumnNumber; j++)
{
printf("%d",***(AdressOfMatrix+i)+j);
}
printf("\n");
}
}
If what i understand is right you want to fill your 2 dimensional array with 1s and 0s so you can do that
That will fill your matrix as you wish and i suggest you to not use dereference operator if you are not good with it square brackets mostly fine.
And if you have an urge to use dereference operator you can use that line