Advertisement
Guest User

atoi

a guest
May 15th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. struct node * insert2(struct node *root, char x[],char id[])
  2. {
  3.  
  4.  
  5. if(!root)
  6. {
  7. root=(struct node*)malloc(sizeof(struct node));
  8. free( root->data ); // free previously allocated memory, if any
  9. root->data = strdup( x ); // malloc and copy
  10. root->id=id;
  11. root->left = NULL;
  12. root->right = NULL;
  13. // printf("1\n");
  14. return(root);
  15. }
  16.  
  17. if(atoi(root->id) > atoi(id)){
  18. root->left = insert(root->left,x,id);
  19. }
  20. else
  21. {
  22. if(atoi(root->id) < atoi(id))
  23. root->right = insert(root->right,x,id);
  24. }
  25. return(root);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement