Archived

This topic is now archived and is closed to further replies.

Pointers

This topic is 5826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

other than what you mentioned, pointers can be used if you want to directly change the value being passed to a function.
for example...

void foo(int *num)
{
*num = 10;
}

int main()
{
int ass = 4;

foo(ass);
}

after the call to foo(), ass will lose its value of 4 and become 10. get it?



...go on and live with no regrets, you only have one life...

Share this post


Link to post
Share on other sites
If calling a function that takes a parameter larger than the size of the pointer itself, its faster to pass a pointer to it instead. Same with returning values, faster to return a pointer than a block of data larger than the pointer.

Storing global variables as pointers to them is better than having the globals as normal variables (again in the case that their size is larger than the pointer... no use having a pointer to a boolean)

-----------------------
0wn 0wn 0wn your goat
gently down the pw33n

Share this post


Link to post
Share on other sites