fork download
  1. /******************************************************************************
  2.  
  3.   Online C Compiler.
  4.   Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12.  
  13. typedef struct node {
  14. char word[50];
  15. struct node *left;
  16. struct node *right;
  17. } node;
  18.  
  19. typedef struct dictionary {
  20. node *root;
  21. int size;
  22. } dictionary_t;
  23.  
  24. dictionary_t* create_dictionary();
  25. dictionary_t* create_dictionary() {
  26. printf("Create Dictionary\n\n");
  27. dictionary_t* dict = malloc(sizeof(dictionary_t));
  28. // free(dict);
  29. return NULL;
  30. }
  31.  
  32. void node_print(const node *node);
  33. void node_print(const node *node) {
  34. printf("Print Node");
  35. }
  36.  
  37. void dict_print(const dictionary_t *dict);
  38. void dict_print(const dictionary_t *dict) {
  39. if (dict == NULL || dict->root == NULL) {
  40. printf("NULL Binary Tree\n\n");
  41. return;
  42. }
  43. node_print(dict->root);
  44. return;
  45. }
  46.  
  47. int main()
  48. {
  49. printf("Hello Binary Tree\n\n");
  50.  
  51. dictionary_t *dict = NULL;
  52. dict_print(dict);
  53. dict = create_dictionary();
  54. dict_print(dict);
  55.  
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0s 5380KB
stdin
Standard input is empty
stdout
Hello Binary Tree

NULL Binary Tree

Create Dictionary

NULL Binary Tree