I've noticed something interesting in C++ programming. I've always done tricky stuff with pointers and references to have functions deal with arrays. Doing exercises again out of a C++ book has shown me an easier way, I didn't even know was there.
Say I pass a two dimensional array to a function and receive it in the function definition, as either int* a or int a[colsize]. I'm surprised that inside the function I cannot access it using both pointers and the normal array notation immaterial of how it was received by the function definition.
[CS241C-01@lewis ~]$ cc Array.c
Array.c: In function ‘main’:
Array.c:23: warning: passing argument 1 of ‘scanf’ makes po
Array.c:25: error: expected expression before ‘return’
Array.c:29: error: expected expression before ‘return’
Array.c: At top level:
Array.c:44: error: expected ‘)’ before ‘&’ token
While learning about multi-d arrays, came across line of text:
----shows that the name of a two-dimensional array has to be dereferenced twice to get a value stored in the array. This can be done by using the indirection operator (*) twice or by using the bracket operator ([ ]) twice.