Passing array to a function in C -
Although we declare a function with an integer array, we pass the address of the array into the function. In the case of simple integers, if we pass the address, we get an error, we get the pointer conversion error. But how is this possible in case of array
contains #lt; Stdio.h & gt; Zero print_array (int array [] [100], int x, int y); Main () {int i, j, arr [100] [100]; Printf ("Insert Array"); {For (j = 0; j & lt; 2; j ++) {scanf ("% d", and arr [i] [j] for i (i = 0; i & lt; 2; i ++) ); }} Print_array (arr, i, j); } Zero print_array (int array [] [100], int x, int y) {int i, j; Printf ("\ n value \ n"); (I = 0; i & lt; x; i ++) {for (j = 0; j & lt; y; j ++) {printf ("% d", array [i] [j]) ; }}} My question is that our function has been declared as the first parameter with integer array (here) when we call the function, we pass the array address Are there. how does it work?
You are passing the array, it does not know arr an int [] [] The array is (in fact this is very similar to and (arr [0]) , which is an indicator (address of) the first line of your array in C, an array and related indicator There is no practical difference between it, except that you find it with Android.) EDIT: OK, just to make me clear: #include & lt; Stdio.h & gt; Int fn (char p1 [] [100], char (* p2) [100]) {if (sizeof (p1)! = Sizeof (p2)) printf ("I've failed.% I
Comments
Post a Comment