Sir, we know that when we call a function, we call it by pass by reference so my doubt is, in the program where you have written a function like void readMatrix(int a[][10], int R,int C); so here a[][10], is it a pointer array which points to the first row of a matrix?
2 D array pointer
@Kinjal Yes the array would be passed here by reference. The base address of the matrix would be passed in this case.
so a[][10] is a pointer which points to the first row of the matrix, then what is ‘a’ signifies which we passed inside main function? like, readMatrix(a, R, C); so, what ‘a’ the delimeter signifies here?
Hello @Kinjal
You are correct “a[][10] is a pointer which points to the first row of the matrix”
“a” is the identifier/name of the matrix here.
It is of the type int**
"a" points to the first row. If you add 1 to "a" then we get the pointer to second row of the matrix.
(a + 1) This is a pointer to the second row
*(a + 1) This is a pointer to the elements of the second row and points to the first element of 2nd row
(*(a + 1) + 5) This is a pointer to the 6th element in the second row
*(*(a + 1) + 5) This is the 6th element in the second row.
If you need any help, leave a reply to this thread and I will get back to you.
But Inside main(), in function we always send address of a variable so that we can play with its value inside the called function, right?
so by that fact we can say that ‘a’ is a address of an array, right?
Hello @Kinjal
Yes, ‘a’ is the address of an array and to play with the array, we can simply send ‘a’ because it contains the address of the array.
You can try and print the value of ‘a’ // cout << a << endl;
You will see that it prints out an address.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.