Save distinct words into linked list

前端 未结 2 1123
死守一世寂寞
死守一世寂寞 2021-01-17 07:39

Basically I have 2 linked list here: list and distinct. There are a few set of words which have been saved earlier into the \'list\' struct. Was gonna write a program that i

2条回答
  •  一向
    一向 (楼主)
    2021-01-17 08:15

    These three lines is one likely culprit:

    if(ori == NULL && copy == NULL) { //first time.
        ori = ori->next;
        copy = copy->next;
    

    Here you check if ori and copy are NULL, then you immediately dereference those NULL pointers!

提交回复
热议问题