Dereferencing Pointers

0 Nicholas Heytens · November 13, 2014
I'm having an issue with the concept of changing the original value of tuna=19 to tuna=71 since 19 is the original value are we changing it because if I throw in a %p it has an entire different memory address:


Post a Reply


Oldest  Newest  Rating
0 c student · December 5, 2014
i believe that when u initialized *pTuna = &tuna, the pointer pTuna now points to the address of tuna, that is pTuna is equivalent to *tuna.  because it directly points to the address where tuna's value of 19 is stored allowing it to be edited.

by dereferencing the pointer *pTuna = 71, you have directly edited the value of tuna in memory where tuna's value is equal to *pTuna.

with this method you are able to indirectly change the value of a variable without having to change the original.  this is what makes C such a beautiful and powerful (although quite confusing) programming language: memory manipulation

disclaimer: this might not be true but this is my best guess
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator