fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. typedef struct treenode
  4. {
  5. int data;
  6. struct node*left;
  7. struct node*right;
  8. }node;
  9. void insert(node*,int);
  10. void del();
  11.  
  12. int BT_add()
  13. {
  14. node *root=(node*)malloc(sizeof(node));
  15. root=NULL;
  16. int select;
  17. int data;
  18. while(1)
  19. {
  20. printf("\n------------Select Work:----------\n");
  21. printf("(0)Exit\n(1)Insert(2)Del");
  22. scanf("%d",&select);
  23. if(select==0)
  24. printf("\n");
  25. break;
  26. switch(select)
  27. {
  28. case 1:
  29. printf("Insert Data:");
  30. scanf("%d",&data);
  31. insert(root,data);
  32. break;
  33. case 2:
  34. del();
  35. break;
  36. }
  37. }
  38.  
  39. system("pause");
  40. return 0;
  41. }
  42. void insert(node*r,int data)
  43. {
  44. node *newnode =(node*)malloc(sizeof(node));
  45. newnode->left = newnode->right =NULL;
  46. newnode->data = data;
  47. if(r==NULL)
  48. {
  49. r = newnode;
  50. }
  51. else
  52. {
  53. newnode = r;
  54. if(data<=r->data)
  55. {
  56. return insert(newnode->left,data);
  57. }
  58. else
  59. {
  60. return insert(newnode->right,data);
  61. }
  62. }
  63. printf("%d Insert Success",data);
  64. }
  65. void del()
  66. {
  67.  
  68. }
  69.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘BT_add’:
prog.c:22: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:30: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:39: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result
prog.c: In function ‘insert’:
prog.c:56: warning: passing argument 1 of ‘insert’ from incompatible pointer type
prog.c:60: warning: passing argument 1 of ‘insert’ from incompatible pointer type
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
stdout
Standard output is empty