0

Bidimensional arrays in C

How do I pass a matrix by reference (not by value I want the array to be used or modified) to a function/procedure in c?

14th Mar 2017, 6:59 PM
infinity
infinity - avatar
2 Réponses
+ 3
char **matrix should do But be careful, it is not by reference but by address
14th Mar 2017, 7:52 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
I want to pass the matrix to this kind of function void printStrings(char *matrix, int nWords, int stringLength){ unsigned int i, ii; for(i=0; i<nWords; i++){ for(ii=0;ii<stringLength;ii++){ printf("%c", matrix[i][ii]); } printf("\n"); } } to print every letter of the words contained in each line of the 2D matrix on separate lines
14th Mar 2017, 7:28 PM
infinity
infinity - avatar