링크드리스트 주소록짜기 질문인데요
맛깔손
링크드리스트 질문!링크드리스트에서 포인터가 다음 항목을 가르키는 방법을 이해못하겠습니다.질문 내용 :
여기가 메인함수말고 짠부분인데 주소록 추가하는부분입니다.
근데 여기서 한번 입력받는건 실행해서되는데요 다음 리스트로 가르키는 방법을 잘모르겠네요
두번입력하면 다시 current 에 덮어쓰기형식으로 저장되는건가요??
#include stdio.h
#include stdlib.h //malloc 함수사용
#include string.h
struct input{
char*studentid;
char*name;
char*phonenumber;
char*address;
struct intput*next; //다음구조체를 가르키는 문장
};
void insert(void)
{
struct input *head=null;
struct input *current, *daum;
char str[100];
current=(struct input*)malloc(sizeof(struct input));
printf(학번입력:\n);
fgets(str, sizeof(str), stdin);
current-studentid=(char*)malloc(strlen(str)+1);
strcpy(current-studentid, str);
printf(이름입력:\n);
fgets(str, sizeof(str), stdin);
current-name=(char*)malloc(strlen(str)+1);
strcpy(current-name, str);
printf(핸드폰번호좀:\n);
fgets(str, sizeof(str), stdin);
current-phonenumber=(char*)malloc(strlen(str)+1);
strcpy(current-phonenumber, str);
printf(주소를 주세요\n);
fgets(str, sizeof(str), stdin);
current-address=(char*)malloc(strlen(str)+1);
strcpy(current-address, str);
if(head==null)
{
current-next=null;
head=current;
}
else
{
head-next=current; -이부분을 모르겟어요 ㅠㅠㅠㅠ
pass-current=null;
}