please help me to find size of array......... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

please help me to find size of array.........

int arrSize = sizeof(arr)/sizeof(arr[0]); //OK it works fine for me,I understood int arrSize = *(&arr + 1) - arr; //I am not able to get it properly As far as I got it, I think (&arr+1) is the address of address which reflects the address of next to whole 'arr'....... dereferencing it will give us back the address of arr end but how? This is all I can understand ulta sidha... please help me to get it.....................

27th May 2021, 10:49 AM
saurabh
saurabh - avatar
6 Answers
+ 2
Martin Taylor thanks a lot buddy to make it clear to me.........
27th May 2021, 1:08 PM
saurabh
saurabh - avatar
+ 2
Martin Taylor Looks like its time for me to revisit some pointer arithmetic concepts in order to enter the esoteric club 😬
27th May 2021, 1:58 PM
Infinity
Infinity - avatar
0
Infinity bro i am talking about (&arr+1) Not (arr+1)
27th May 2021, 11:46 AM
saurabh
saurabh - avatar
0
Infinity bro please describe me how 2nd method provides size of an array???
27th May 2021, 11:50 AM
saurabh
saurabh - avatar
0
Infinity bro you were wrong .. arr+1 means memory address of array element at index 1 *(arr +1 ) means arr[1]
27th May 2021, 12:09 PM
saurabh
saurabh - avatar
0
I never said `arr+1` is equivalent to `*(arr+1)`
27th May 2021, 12:21 PM
Infinity
Infinity - avatar