Skip to main content
gamedev.net
🔒 Locked

pointing pointers

Started by guyaton Apr 6, 2005 at 2:47 PM 4 replies 650+ views
Original Post
guyaton
guyaton
I am trying to use a pointer to point to a pointer. a simplified version of what I am doing looks like this:

int **someI = NULL;
someI = new int*[1];
someI[0] = new int;

after executing the second line, someI is still = 0x00000000. what am i doing wrong? ~guyaton
~guyaton
doho
doho
Quote:
Original post by guyaton
after executing the second line, someI is still = 0x00000000. what am i doing wrong?

Nothing from what I can see. For me, after the second line is executed someI isn't NULL.
guyaton
guyaton
I started it in a new program and it works fine....weird. i wonder y in my program it doesn't work.

~guyaton
crusadingknight
crusadingknight
Quote:
Original post by guyaton
I started it in a new program and it works fine....weird. i wonder y in my program it doesn't work.

You're certain you're not setting it to NULL or redeclaring it elsewhere by acccident? :\ Otherwise, that shouldn't be possible, unless it's in an uncalled function.
Qw3r7yU10p!
Qw3r7yU10p!
Quote:
Original post by guyaton
I am trying to use a pointer to point to a pointer.

So you're almost a ThreeStarProgrammer.

you could use std::vector to make things simpler.

std::vector<int*> someI(1);someI[0] = new int;//or evenstd::vector<int> someI(1);
Omaha
Omaha
1.) How are you checking that it is in fact NULL?
2.) Are you sure you aren't actually looking at the dereferenced value, which may or may not cause the program to explode?
3.) If you only need one, why are you using an array?

"Simplified versions" of code snippets frequenty simplify out the issue.... Are you sure there's not something else happening in there?

Topic Locked

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

Sign in to reply to this topic.