0

Hey guys, i saw this code in a challenge and I can't understand the (*(*(arr+1))) part, I'll be thankful if someone explain it ❀

Arr x Pointer problem https://code.sololearn.com/c7OhgQzRadS9/?ref=app

27th Mar 2021, 7:50 PM
Mehrshad Mohammadi
Mehrshad Mohammadi - avatar
8 Answers
+ 5
its a reference to the first value of the second "row" of data. if the array is: {2,3,4, 5,6,7} and if *(arr) is equal to the entire first row, then *(*(arr)) would be the first value of the first row
27th Mar 2021, 8:25 PM
Slick
Slick - avatar
+ 3
No problem! And i know its for c, but pointers are pointers. Check this out if you have some questions https://www.sololearn.com/learning/2933/
27th Mar 2021, 8:30 PM
Slick
Slick - avatar
+ 1
Slick I'll sure do! Thanks again đŸ™đŸ»
27th Mar 2021, 8:32 PM
Mehrshad Mohammadi
Mehrshad Mohammadi - avatar
+ 1
Slick --> Your explanation of that output is not a part of that lesson you are pointing to, but it's the same as using this method: The first element from the second dimension..... printf("%d", arr[1][0]); The array is also confusing, because it stands out as the input is in one dimension and not two.
27th Mar 2021, 10:24 PM
Jan
Jan - avatar
+ 1
Now, I know how that pointer access to multi arrays works... cout<< (*(*(arr+1)+1)); //The second element from the second dimension cout<< (*(*(arr)+2)); //The third element from the first dimension
27th Mar 2021, 11:11 PM
Jan
Jan - avatar
0
The output seems to be the sum of rows and columns in the multi-dimentional array.
27th Mar 2021, 8:20 PM
Jan
Jan - avatar
0
Quantum Great 😅but can you explain the mechanism of it, just a little bit?
27th Mar 2021, 8:24 PM
Mehrshad Mohammadi
Mehrshad Mohammadi - avatar
0
Slick thanks That's so Helpful! Thanks alot đŸ€©đŸ‘ŒđŸ»
27th Mar 2021, 8:28 PM
Mehrshad Mohammadi
Mehrshad Mohammadi - avatar