How to pass a 2D array as a pointer ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
6th Dec 2022, 6:55 PM
Ox73hahd
Ox73hahd - avatar
1 Answer
+ 4
Function signature: void p(short arr[][2]) { ... } Invocation: p(arr); This is really a bit confusing. Arrays are actually pointers, and a multidimensional array variable stores pointers to another pointer. The [ ] notation is basically just syntactic sugar. In the function header you must specify at least the size of the second array dimension, or you can even specify all of them, or use pointer syntax. https://www.geeksforgeeks.org/pass-2d-array-parameter-c/ https://code.sololearn.com/cNm1E5gTNW8J/?ref=app
6th Dec 2022, 7:26 PM
Tibor Santa
Tibor Santa - avatar