I'm not sure about this - no expert here - but something seems off to me in this logic.
You assign a value to BSTNode** root, even though it is null.
To me that would imply that [code*root[/code] holds an address to that nullpointer.
If [code]*root[/code] were NULL - it wouldn't point to the **root - it would point nowhere.
Hence you get a segfault when trying to read from it.
Hopefully that can help you understand the problem, let us know if you need more specific directions to a solution and I'm sure one of the experts around here will be happy to help.
#include <stdlib.h>
#include <iostream>
#include "bst.h"
usingnamespace std;
int main() {
BSTNode* root = NULL; // Note: this is the pointer to the root
addNode(&root, 5); // Now provide the pointer to the pointer to root (so that you can modify the pointer to root)
return 0;
}