Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct TreeOfWords{
- char* s;
- }TreeOfWords;
- void InsertWord(TreeOfWords*** words, char *s, int *countOfItems) {
- TreeOfWords *p = (TreeOfWords*)malloc(sizeof(TreeOfWords));
- p->s = (char*)malloc(strlen(s)+1);
- strcpy(p->s, s);
- *words = (TreeOfWords**)realloc(words, (*countOfItems+1)*(sizeof(TreeOfWords*))); //Erroe occurs here
- (*words)[(*countOfItems)] = p;
- }
- int main()
- {
- int count = 0;
- TreeOfWords** words = NULL;
- char* pch = 'hello'; // actually i am using here while loop and many strings, but here will be just one word
- InsertWord(&words, pch, 0);
- *words = realloc(words, (*countOfItems+1)*(sizeof(TreeOfWords*)));
Add Comment
Please, Sign In to add comment