459,183 Members | 1,134 Online Need help? Post your question and get tips & solutions from a community of 459,183 IT Pros & Developers. It's quick & easy.

# finding matrix transpose - why doesn't it work when passing pointer argument?

 P: 1 Hi I'm adapting some code I've written using 2d arrays (to represent matrices) to handle large arrays such that double matrix[][] goes to double **matrix and then I'm using malloc. It seems to work fine for part of my program up to where I have to find the matrix transpose at which point it does something I don't understand. I've taken that bit of code out and run it by itself (included below), get the same problem... which is that the input matrix is getting modified when the function is called, here's an example for a test 3 by 3: The input is:in = 10.000000 in = 10.000000 in = 10.000000 in = 5.000000 in = 5.000000 in = 5.000000 in = 3.333333 in = 3.333333 in = 3.333333 but after being passed to find_transpose is comes out as:in = 10.000000 in = 10.000000 in = 10.000000 in = 10.000000 in = 5.000000 in = 10.000000 in = 3.333333 in = 3.333333 in = 10.000000 and the actual transpose output is: out = 10.000000 out = 10.000000 out = 10.000000 out = 10.000000 out = 5.000000 out = 3.333333 out = 10.000000 out = 10.000000 out = 10.000000 I really don't understand why!? Can anyone help?? Thanks jbd nt find_transpose(int n, double **a, double **b) { int i,j; for (i=0; i 