구조체 연결리스트 질문드려요~
매1혹
2023.04.01
연결리스트를 만들고 그것에 대한 복사!연결리스트를 만들고나서 그것을 복사하는 방법 질문 내용 :
#includestdio.h
#includestdlib.h
struct node{
int data;
struct node *next;
}a;
void main(){
int i;
struct node *head=null, *p;
for(i = 0 ; i 4 ; i ++){
p=(struct node*)malloc(sizeof(struct node));
printf(정수 한 개 를 입력하세요. : );
scanf(%d, &p-data);
p-next=head;
head=p;
}
for(p = head ; p != null ; p = p-next){
printf(-%d, p-data);
}
}
여기까지는 제가 만든 연결리스트이구요
이 연결리스트를 인자로 받아서 복사된 연결리스트에 대한 시작주소를 반환하는 함수 copylist를 만들어야하는데
여기서 어떻게 해야되는지 모르겠어서요ㅠㅠ
struct node *q;
q = copylist(head) 이것을 써서 해야되는거같긴한데
정확하게 모르겠으니, 답변부탁드릴게요!
소스만 써주시지 마시고 설명까지 부탁드려요