Help Needed: Clarification on Pointers as Parameters

Hello,

I was reviewing some code and I came across syntax that I didn't understand. I was wondering if anyone could explain the following. I've included the code that I think is relevant but if additional code is required I can post that as well. I'm wondering about the parameter node**. I understand pointers but I assumed pointers only need one *. Anybody know what it means when the functions have parameters such as node** head_ref and node**?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
struct dataSource
{
	string	information
};

struct node
{
	dataSource data;
	struct node* nextNode;
};

//Function declarations
void push(node** head_ref, dataSource new_data);
void readFile(node**, string);
node* → pointer to node
node** → pointer to node* → pointer to pointer to node
closed account (E0p9LyTq)
I could be wrong, or not totally accurate, but from what I know and can dig up the ** is one method to indicate a pointer to an array.

int main(int argc, char **argv);
vs.
int main(int argc, char *argv[]);
Also you might want to change pointer itself:
1
2
3
4
5
6
7
8
9
10
11
12
13
char* buffer = new char[10];
foo(&buffer, 10);

//...
void foo(char** buf, size_t size)
{
    //...
    if (size < needed_size) {
        delete[] *buf;
        *buf = new char[needed_size];
    }
    //...
}
closed account (E0p9LyTq)
@MiiNiPaa,

Thanks for the info.

@NoCompletion,

I found the following that might help make understanding pointers to pointers easier to understand:

http://www.tutorialspoint.com/cplusplus/cpp_pointer_to_pointer.htm
FurryGuy and MiiNiPaa,

Thank you both for the information. That clears up the question that I had.
Topic archived. No new replies allowed.