View Single Post
 
Reply
Posted 2006-02-07, 04:56 PM in reply to sciencekid's post starting "all right then, i'll try to practice..."
They are both correct. A pointer holds an address in memory. If you outputted the value of a pointer, you would get a memory address, which pretty much would look like random garble. However, you can use a pointer to change the value of a variable as well. By using the correct command, you basically say change the value of the address a pointer is pointing to. For instance, lets say pointer i points to variable x, and variable x's location in memory is 1234:5678. Lets say x is initially 10. If you wanted to change x's value to 20, you could do so using the pointer like so:

Code:
 *i = 20;
What that code does is it says, go to the address that i is holding, which also happens to be variable x's location, and change the value that address i is holding to 20, which therefore also changes x's value.
Old
Profile PM WWW Search
Demosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to beDemosthenes seldom sees opportunities until they cease to be
 
Demosthenes