recursion in linked list to remove node

hi guys. while running this program, i am getting program stopped working error. i want to remove a particular node in linked list by recursion. here is partial code for that which I believe contains the error. any help would be appreciated!

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
33
34
35
36
37
38
39
40
41

data* recursion(int nth_info,int zero)///to get to particular list///int zero to always be kept zero///here info= 1 single node of linked list
{
    data* p_current;
    if(zero==0)
    {
         p_current=p_list; ///p_list=beginning of list, global variable
    }
    ++zero;
    if(zero==nth_info)
    {
        return p_current;
    }
    else
    {
        recursion(nth_info,zero);
    }
}


void remove_nth_info(int nth_info)
{
    data* p_to_remove=recursion(nth_info,0);
   /* if(p_to_remove->p_previous_info==p_list)
    {
        p_list=NULL;
    }
    else
    {*/
    p_to_remove->p_previous_info->p_next_info=p_to_remove->p_next_info;///if i comment it out, dont get error!
    ///}
}


int main()
{
    ///adding new items in list here
    remove_nth_info(2);
}

Topic archived. No new replies allowed.