Best way to check if pointer is initialized

Viewed 14701

Is there a way to check if pointer was initialized? I have a struct that cointain array of pointers

typedef struct foo
{
    int* ptr1;
    int* ptr2;
    int* ptr2;
    ...
    int* ptr100;
}

and then my code is assigning adresses to those pointers (inside loop). But before adress is assigned i want to check if pointer is already containing adress. I know that i can initliazie every pointer with NULL and then check this with:

if(ptr1 == NULL)
    do something

But is there way to write something similiar but without initialization of ptr?

2 Answers
Related