Hi all! would like some help, hopefully someone can enlighten me.
My program has for input a 2d array where the number of rows and columns is decided by the user.

So in the code below, the matrix A is the input matrix and the matrix Q is the matrix to be calculated with the function maqr.
however, as i'm reusing the matrix A as a 1d array in the function maqr, i'm not too sure how to declare the arrays in his function.
Any help will be apreciated!

void main(void)

    extern int maqr();
    int i, j;                  /* Loop counter                   */
    int w; 
    int R,C;                   /* Order of Matrix                */
    double**A;             /* Matrix                      */

    printf("Please enter rows of Matrix  A \n"); 
    printf("Please enter columns of Matrix  A \n";
   A = (double **) malloc(sizeof(double *) * R);
        for(i = 0; i < R; i++)
                A[i] = (double *) malloc(sizeof(double) * C);

   Q = (double **) malloc(sizeof(double *) * R);
        for(i = 0; i < R; i++)
                Q[i] = (double *) malloc(sizeof(double) * R);

int maqr(a,m,n,q)
  int m,n;
  double a[];
  double q[];
Votes + Comments
Used code tags on first post :)
7 Years
Discussion Span
Last Post by jephthah

Declare maqr() like this:

int maqr(double* a[], int m, int n, double* q[])
    // and access the elements of a and q like this:
    double x = *a[0];

i believe you will want to call the maqr() function after you've allocated the memory sizes.

also, remember to always use "free" after you're done with the allocated arrays.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.