프로그래밍 중 자료구조에 관하여 질문드립니다.

-main함수

  1. #include <stdio.h>

  2. #include "Com_In_head.h"

  3. int main(void)

  4. {

  5. List plist;

  6. ListInit(&plist);

  7. Linsert(&plist, 154998, "kim");

  8. Linsert(&plist, 141850, "jin");

  9. Linsert(&plist, 176236, "park");

  10. Linsert(&plist, 187649, "harry");

  11. return 0;

  12. }


-헤더파일

  1. #ifndef __Com_In_Head__

  2. #define __Com_In_head__

  3. typedef struct ComH

  4. {

  5. int Hnum;

  6. char *Hname;

  7. }ComH;

  8. typedef struct _node

  9. {

  10. ComH *data;

  11. struct _node * next;

  12. }Node;

  13. typedef struct _Cll

  14. {

  15. Node *tail;

  16. Node *cur;

  17. Node *before;

  18. int numOfData;

  19. }List;

  20. void ListInit(List *plist);

  21. void Linsert(List *plist, int Hnum,char *Hname);

  22. /*int Lfirst(List *plist, int *pdata);

  23. int Lnext(List *plist, int *pdata);

  24. int Lremove(List *plist);

  25. int Lcount(List *plist);*/

  26. #endif

-헤더파일에 선언된 함수코드

  1. #include <stdio.h>

  2. #include "Com_In_Head.h"

  3. void ListInit(List *plist)

  4. {

  5. plist->tail = NULL;

  6. plist->cur = NULL;

  7. plist->before = NULL;

  8. plist->numOfData = 0;

  9. }

  10. void Linsert(List *plist, int HNum, char *HName)

  11. {

  12. Node *newnode = (Node*)malloc(sizeof(Node));

  13. newnode->data->Hnum = HNum;

  14. newnode->data->Hname = HName;

  15. if (plist->tail == NULL)

  16. {

  17. plist->tail = newnode;

  18. newnode->next = newnode;

  19. }

  20. else

  21. {

  22. plist->tail->next = newnode;

  23. newnode->next = plist->tail->next;

  24. plist->tail = newnode;

  25. }

  26. plist->numOfData++;

  27. }


보기가 명확하지는 않은데요!

Linsert함수에서

newnode->data->Hnum = HNum; newnode->data->Hname = HName;

이 코드가 쓰기 엑세스 위반이라고 뜨는데 이유가 뭔가요?

    아직 답변이 없어요.