Is there a way to ensure that all un-initialized pointers automatically have the address 0x00000000? Sometimes they're being set to other addresses but still being unitialized, and they pass tests like if(!ptr), causing an unhandled access violation error.
tomtetlaw
-1
Posting Pro
Recommended Answers
Jump to PostJust set the pointer to NULL.
void *vptr = (void*)NULL;
You should get into a habit of initializing all pointers to NULL and all freed pointers to NULL.
Jump to Post>Sometimes they're being set to other addresses but still being unitialized, and
>they pass tests like if(!ptr), causing an unhandled access violation error.
That's the whole point, genius. If you're trying to use an uninitialized pointer, that's a Bad Thing™, and it should be immediately fatal as it's a programming …
All 6 Replies
gerard4143
371
Nearly a Posting Maven
tomtetlaw
-1
Posting Pro
Narue
5,707
Bad Cop
Team Colleague
tomtetlaw
-1
Posting Pro
Narue
5,707
Bad Cop
Team Colleague
tomtetlaw
-1
Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.