The question is &str[2], if I write str+2 then it would give the address and its logical but where did I used pointer notation in it?
Should I prefer writing &(*(str+2))?
The question is &str[2], if I write str+2 then it would give the address and its logical but where did I used pointer notation in it?
Should I prefer writing &(*(str+2))?
You can use either
&str[2]
or
(str + 2)
Both of these are equivalent.
This is pointer arithmetic. So when you mention an array str or &str you refer to the base address of the array (in printf for example) i.e. the address of the first element in the array str[0].
From here on, every single increment fetches you the next element in the array. So str[1] and (str + 1) should give you the same result.
Also, if you have num[] = {24, 3}
then num[0] == *(num + 0) == *(0 + num) == 0[num]
&(str + 1) shouldn’t work (didn’t actually check but pretty certain) because you can’t use the address-of operator on a pointer. Secondly, &num[0] == num[0] is wrong, and so is the rest of your equation.&(str+1) is invalid because you can't take the address of a temporary variable, not because you can't take the address of a pointer...!&str and str are not the same thing. In particular, (str+1) and (&str+1) will not point at the same address (unless the array happens to be of length 1).