Skip to main content
gamedev.net
🔒 Locked

Pointers and functions

Started by guyaton 2 replies 200+ views
Original Post
guyaton
guyaton
What I am trying to do is send a pointer in a function, and inside that function create that pointer of some size (which can only be determined inside the function) and then store information to that pointer. When I exit the function I want to be able to access/use that information. How do I do that? ~Guyaton
~guyaton
alnite
alnite
function_name( data_type** ptr )

OR

function_name( data_type*& ptr )
guyaton
guyaton
That was much simpler that I was trying to do! thnx!



~Guyaton
~guyaton
Promit
Promit
I''ll just butt in and recommend the latter form:
function_name( data_type*& ptr)
because it forces the pointer itself to be a valid variable (though it does not necessarily point to something valid!). If you use data_type**, it''ll force you to do another NULL check.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.