Created
January 8, 2022 09:52
-
-
Save Tony363/1998929b4db34cbd8204303c6d7ca3ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int n_chars, offset = 0; | |
CBinTreeNode *_buildCBinTree(CBinTreeNode *root, const char *s) | |
{ | |
char word[10]; | |
if (sscanf(s + offset, "%s%n", word, &n_chars)) | |
offset += n_chars; | |
else | |
return NULL; | |
if (word[0] == '@') | |
return NULL; | |
root = createNode(word); | |
root->left = _buildCBinTree(root->left, s); | |
root->right = _buildCBinTree(root->right, s); | |
return root; | |
} | |
CBinTree *buildCBinTree(const char *s) | |
{ | |
CBinTree *tree = (CBinTree *)malloc(sizeof(CBinTree)); | |
tree->root = _buildCBinTree(tree->root, s); | |
return tree; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment