링크리스트 insert 함수만들었는데 이상한데서 오류가 나요

질문 제목 : typedef struct _node
{
ldata data;
int score;
struct _node *next;
}node;
typedef node *list;
void init(list l){
l-data = -1;
l-score = -1;
l-next = null;
}
void insert(list l, int data, int score){
list tmp;
tmp = l;
while(tmp-next!=null)
{
tmp=tmp-next;
} 여기 에러 원인이 뭘까요 ㅠㅠ
tmp-next = (node *)malloc(sizeof(node));
tmp-next-data = data;
tmp-next-score = score;

}
질문 내용 :

댓글 4

  • Soeun 2026.01.06

    list도 값으로받기때문에 콜바이벨류가되구요

  • 나오 2026.01.06

    초기에 temp널로 초기화햇는데 while문에서
    temp-next로비교하네요 null의 next접근하는꼴

  • 어둠 2026.01.06

    노드 새로 생성하고 노드 next에 뭐가 들어가져

  • 새누 2026.01.06

    전체소스를 봐야 알것 같네요

C언어 다른 글

목록