I am building a binary search tree, but the function is giving segmentation fault. I don't know where is the problem.
The tree doesn't build the part in the insertintree does not work properly and I have tried ways but it is not working
#include<bits/stdc++.h>
using namespace std;
struct node // structure of node
{
    int k;
    node* left = NULL;
    node* right = NULL;
};    
void insertintree(node* root, int key)
{
    if (root == NULL)//root addition
    {
        node* root = new node;
        root->k = key;
    }
    else 
    {
        if (root->k < key)  insertintree(root->right, key);
        else insertintree(root->left, key);
    }
}    
void inorder(node* root) 
{
    if (root != NULL) 
    {
        inorder(root->left);
        cout << root->k;
        inorder(root->right);
    }
}    
int main() 
{
    node* root = NULL;
    insertintree(root, 1);
    cout << root->k;
}
 
     
    