String Tree

Hello guys!
I just started with C development and I'm trying to make a C program wich will read some informations from a ".txt" file and make a Tree with some IDs.

Everything works fine, until the 35th line. When my file got more than 35 lines, my program doesn't even starts reading (Error: Process terminated with status -1073741819).

This is my insert function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*	arv = my tree struct
**	* a = pointer to my tree struct
**	b[98] = the ID i want to insert
*/

arv *ins(arv * a, char b[98])
{
    arv * q;
    int num;

    if (a == NULL)
    {
        q = (arv*) malloc (sizeof(char)*98);
        strcpy(q->id,b);
        q->left = NULL;
        q->right = NULL;
        a = q;
    }
    else
    {
        num = strcmp(b,a->id);
        if (num < 0)
        {
            a->left = ins(a->left,b);
        }
        if (num > 0)
        {
            a->right = ins(a->right,b);
        }
    }
    return a;
}


Do you think the problem is there?
Let me know if you need more info about the code.

Thanks in advance
Last edited on
Oh! Feel so shamed... I forgot to check if q == NULL...
so my problem is memory error =P

Thanks anyway ^^
Topic archived. No new replies allowed.