Hi could someone tell me how to pass a dynamic matrix to a function? Or where I have gone wrong? Thanks for the help!

for example:

void main()
int R,C;           /* r=rows, c=columns/*
double *A;     /* A is the matrix/*

/* I dynamically allocate my matrix (not too sure if correct)*/
double *A = malloc(R * C * sizeof(double)); 

/* assuming i have a function that calculates the determinant */

/* and free it later*/

void determinant(double *matrix, int r, int c)

have I passed the dynamic matrix to the function determinant correctly?

quick note:

you've already declared 'A' as type double * ... so don't declare the type a second time when you allocate the memory

otherwise you're passing the pointer as declared correctly, but you may want to reconsider how you define the array to begin with.

This question has already been answered. Start a new discussion instead.