I am still struggling to understand the difference between *p, &p, and p. From my understanding, * can be thought of “value pointed by”, and & as “adress of”. In other words, * holds the value while & holds the adress. If this is true, then what is the distinction between *p and p? Doesn’t p hold the value of something, just like *p?
Share
The
*operator is used for indirection. Indirection means the value inpis interpreted as a memory address and the value at that address is loaded.pis the value ofpwhile*pis the value stored in the memory location pointed byp. When you want to indirectly access the value of an integeri, you can have an integer pointer point to it (int *p = &i) and use that pointer to modify the value ofiindirectly (*p = 10).