443,626 Members | 2,202 Online Need help? Post your question and get tips & solutions from a community of 443,626 IT Pros & Developers. It's quick & easy.

# Matrix as an argument

 P: n/a I need to pass a two dimensional matrix to a function. Function gets int ** but i cannot find appropriate input to function in main. in main mdelc(&ar1, 5, 5, 3); function prototype: void mdelc(int **ar1, int a, int b, int d) Sep 1 '07 #1
4 Replies

 P: n/a "Dinçay Akçören" I need to pass a two dimensional matrix to a function. Function gets int ** but i cannot find appropriate input to function in main. in main mdelc(&ar1, 5, 5, 3); function prototype: void mdelc(int **ar1, int a, int b, int d) int **ar; ar = malloc(height * sizeof(int *)); for(i=0;i

 P: n/a On 2 Eylül, 00:38, "Malcolm McLean" = d) arr[i][j] = arr[i+1][j]; if (i == b-1) arr[i][j] = 0; } } } arr is a*b matris, row d is deleted, then remaining part is shifted to left. Sep 1 '07 #3

 P: n/a "Dinçay Akçören" = d) arr[i][j] = arr[i+1][j]; if (i == b-1) arr[i][j] = 0; } } } arr is a*b matris, row d is deleted, then remaining part is shifted to left. >>>>>>>>> It should work as I described. arr is a pointer to a list of pointers. arr[i][j] accesses the i th row and j th column of the matrix. a and b have to be matrix height and width. Sep 2 '07 #4

 P: n/a On Sat, 01 Sep 2007 15:38:29 -0700, "Dinçay Akçören" On 2 Eylül, 00:38, "Malcolm McLean" "Dinçay Akçören" I need to pass a two dimensional matrix to a function. Function gets int ** but i cannot find appropriate input to function in main. in main mdelc(&ar1, 5, 5, 3); function prototype: void mdelc(int **ar1, int a, int b, int d) int **ar;ar = malloc(height * sizeof(int *));for(i=0;iHere is the function Show the code that calls the function. Preferably a compilable unit. >void mdelr(int **arr, int a, int b, int d ){ int i; int j; for (i=0; i= d) arr[i][j] = arr[i+1][j]; When i = b-1, this invokes undefined behavior by access arr[b][j], non-existent elements of the array. You could reverse these two if blocks and make the test on d an else if. if (i == b-1) arr[i][j] = 0; } }}arr is a*b matris, row d is deleted, then remaining part is shifted toleft. Remove del for email Sep 3 '07 #5

### This discussion thread is closed

Replies have been disabled for this discussion. 