I need to write an AVL insertion algorithm but no matter how hard i tried i couldnt . i will just read from a file for records like 30,60,70,50,20,40,10,80 and then will print them on the screen by using preorder traversal of BST. i implemented a struct algorthm for nodes

typedef struct node
struct node * left;
struct node * right;
int record;
} a_node;

typedef struct tree
NODE * root;
} a_tree;

and did the insertion construction on this but i always gives me errors. i understand the algorithm but cant implement the code.
Please help!!!