Hello everyone. I'm writing a program that reads in a text file with words, 1 on each line, and reads it into a binary search tree.

I am using Dev-C++. I'm not sure why i'm getting an error because whenever i run it in debug mode, it runs completely smoothly, but when I run it in normal mode my program crashes.

The question is, why am i getting crashes? And why would it work completely fine in debug mode!?

Without further ado, here's the code and the test file.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node
{
   char* data;
   struct node* left;
   struct node* right; 
};

struct node* insert(struct node* root, char* value);

struct node* insert(struct node* root, char* value)
{
    struct node* newNode;
    if(root == NULL)
    {
        newNode = malloc(sizeof(struct node));
        newNode->data = malloc(sizeof(value));
        strcpy(newNode->data,value);
        newNode->left = NULL;
        newNode->right = NULL;
        
        return newNode;
    } 
    
    if(strcmp(root->data,value) == 0)
        return root;

    if(strcmp(value,root->data) < 0)
    {
        root->left = insert(root->left, value);
        return root;
    }
    else
    {
        root->right = insert(root->right, value);
        return root;
    }
}


int main(void)
{
    char filename[256];
    char tempstr[100];
        
    printf("Whats the dictionary file you're using?\n");
    scanf("%s",filename);
    FILE *dictionaryfp;
    dictionaryfp = fopen(filename,"r");
    struct node* root = NULL;
    
    while (!feof(dictionaryfp))
    {
          fgets (tempstr , 100 , dictionaryfp);
          root = insert(root,tempstr);
    }
    
        
    printf("What do you want to search for?");
    char tempstring[256];
    scanf("%s",tempstring);
    printf("found?: %d",find(root,tempstring));
    
    system("PAUSE");
    
}
Text file:

Code:
nemy
gossamer
foreign
Shearer
flounder
wordy
pellet
Sagittarius
conformation
husky
intersect
Kaplan
birthright
ordinary
knight
cytoplasm
detestation
aureomycin
omen
pasteboard
Abidjan
aromatic
august
Katowice
executive
Jessie
digress
sequestration
satiric
abate
Semite
rigid
anthropomorphism
ongoing