Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int trie_insert ( trie_node_t ** rootRef, char word[ ] ){
- int i=0, index=0;
- int len;
- trie_node_t *tmp = *rootRef;
- len = strlen(word);
- for(i = 0;i<len;i++){
- word[i] = tolower(word[i]);
- }
- if (tmp == NULL) return EXIT_FAILURE;
- for (i=0;i<len;i++) {
- if (word[i] == '\0') index = 26;
- else if (word[i] >= 'a' || word[i] <= 'z') {
- index = charToInt(tolower(word[i]));
- }
- else return EXIT_FAILURE;
- if (!tmp->child[index]) tmp->child[index] = trie_new();
- tmp = tmp->child[index];
- }
- tmp->end= '\0';
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement