Archived

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

How to check if my pointer value has been set yet....

This topic is 5176 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

the_phantom is correct.

If you declare a pointer, then it initially points to nothing. A pointer that points to nothing is called a ''NULL'' pointer. So to check whether a pointer actually points to something, you simply check whether that pointer is NULL or not, like the_phanton did.

Share this post


Link to post
Share on other sites
quote:
Original post by chacha
If you declare a pointer, then it initially points to nothing. A pointer that points to nothing is called a ''NULL'' pointer. So to check whether a pointer actually points to something, you simply check whether that pointer is NULL or not, like the_phanton did.

Careful there. When you declare a pointer, it doesn''t initially point to NULL. It points to some random memory location that is most likely outside of your program''s memory area (IIRC, on MSVC debug it''s usually 0xC4C4C4C4) and thus will make the program crash if accessed. That''s why it''s important to always initialize your pointers to NULL (or 0) when declaring them.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
quote:
Original post by chacha
If you declare a pointer, then it initially points to nothing. A pointer that points to nothing is called a ''NULL'' pointer. So to check whether a pointer actually points to something, you simply check whether that pointer is NULL or not, like the_phanton did.

Careful there. When you declare a pointer, it doesn''t initially point to NULL. It points to some random memory location that is most likely outside of your program''s memory area (IIRC, on MSVC debug it''s usually 0xC4C4C4C4) and thus will make the program crash if accessed. That''s why it''s important to always initialize your pointers to NULL (or 0) when declaring them.


How appropriate. You fight like a cow.

Yes, thanks for correcting me Sneftel.

Share this post


Link to post
Share on other sites