Trying to make linkedlist in C

后端 未结 4 907
余生分开走
余生分开走 2021-01-27 19:43

I am trying to make a struct in C that is a linked list. I am not really sure what is going wrong though. My errors are:

linked.c:6:2: error: unknown type name         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-27 20:21

    in makeList change

    second.rest = &c;
    first.rest = &b;
    

    to

    ll.rest = &second;
    second.rest = &third;
    

    in the original you were giving the adresses of the int variables instead of the linkedList nodes. also, you had a variable 'first' which was never declared, that's where one of errors were taking place.

    also try declaring all your variables first, it makes it easier to read.

提交回复
热议问题