I need to create a matrix calculator, for that I think the best is to create functions for +,-,*,/
.
But a lot of troubles come with this idea.
I create a calloced array like:
int **matrix = NULL;
matrix=calloc(cols,sizeof(int*));
for(int i=0;i<cols;i++) {
matrix[i]=calloc(rows,sizeof(int*));
}
For now I want to create a function where I want to work with this array.
void addition(int **array,int rows, int cols){
// ** some algoritm here**
return (the result of addition stored in 2D array);
}
I also tried to google the problem, but I didn't underestand the solutions. What I need to explain the way how to pass the array to function, just for reading.
After that I need to return some pointer to new array created as the result of addition. I will probably create the new array in the function.
But If I wanted to write something in array created in main, how to pass and use it in the function?