C언어 자료구조 링크리스트 오류 질문입니다
설화
질문 제목 : c언어 자료구조 링크리스트 오류 질문입니다.c언어 자료구조 링크리스트 오류 질문합니다.질문 내용 :
#include stdio.h
#include stdlib.h
typedef int element;
typedef struct listnode {
element data;
struct listnode *link;
} listnode;
void error(char *message)
{
fprintf(stderr,%s\n, message);
exit(1);
}
void inxert_node(listnode **phead, listnode *p, listnode *new_node)
{
if(*phead == null){
new_node-link = null;
*phead = new_node;
}
else if (p == null){
new_node-link = *phead;
*phead = new_node;
}
else {
new_node-link = p-link;
p-link = new_node;
}
}
void remove_node(listnode **phead, listnode *p, listnode *removed)
{
if(p == null)
*phead = (*phead)-link;
else
p-link = removed-link;
free(removed);
}
void display (listnode *head)
{
listnode *p=head;
while(p != null) {
printf(%d, p-data);
p=p-link;
}
printf(\n);
}
listnode *search(listnode *head, int x)
{
listnode *p;
p = head;
while(p!=null){
if(p-data == x) return p;
p = p-link;
}
return p;
}
listnode *concat(listnode *head1, listnode *head2)
{
listnode *p;
if (head1 == null) return head2;
else if(head2 == null) return head1;
else {
p = head1;
while (p-link != null)
p= p-link;
p-link = head2;
return head1;
}
}
listnode *reverse(listnode *head)
{
listnode *p, *q, *r;
p= head;
q= null;
while (p!= null){
r = q;
q = p;
p = p-link;
q-link = r;
}
return q;
}
listnode *create_node(element data, listnode *link)
{
listnode *new_node;
new_node= (listnode*)malloc(sizeof(listnode));
if(new_node==null) error(메모리 할당 에러);
new_node-data = data;
new_node-link = link;
return(new_node);
}
void main()
{
listnode *list1=null, *list2=null;
listnode *p;
insert_node(&list1, null, create_node(10, null));//insert_node 이 부분 밑에 빨간줄이 그여지면서 오류가 납니다.
insert_node(&list1, null, create_node(20, null));
insert_node(&list1, null, create_node(30, null));
display(list1);
remove_node(&list1, null, list1);
display(list1);
insert_node(&list2, null, create_node(60, null));
insert_node(&list2, null, create_node(70, null));
insert_node(&list2, null, create_node(80, null));
display(list2);
list1 = concat(list1, list2);
display(list1);
list1 = reverse(list1);
display(list1);
p = search(list1, 30);
if (p != null)
printf(탐색성공: %d\n, p-data);
else
printf(탐색실패!!\n);
}
주석 적은 부분의 insert_node 이 부분 밑에 빨간줄이 그여지면서 오류가 납니다.
어떻게 해결해야지 실행결과가 나옵니까?
답변에서 -을 =로 고쳤는데도 주석 적은 부분의 insert_node 빨간줄이 그여지면서 오류가 계속납니다.
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692483 | C언어 함수, Header | 떠나간그놈 | 2025-04-23 |
2692451 | 이 문제좀 풀어주세요 ^^ | 게자리 | 2025-04-23 |
2692424 | 2차원배열 자료입력질문이요! (1) | 똘끼 | 2025-04-22 |
2692401 | 유닉스안에서 C언어를 이용한 명함 만들기 입니다; 이해안가는 부분이있네요 | 2gether | 2025-04-22 |
2692374 | 고수님들 댓글 마니부탁해요!!! (2) | 엄지 | 2025-04-22 |
2692343 | scnaf에 자꾸 선언을 참조하라는데;; (8) | 도래 | 2025-04-22 |
2692282 | 도스상에서 생성된 exe파일에 press~ 뜨게 하기 (4) | 회사원 | 2025-04-21 |
2692256 | scanf("%*c"); ㅠㅠ 고수님들 | 거북이 | 2025-04-21 |
2692230 | 하노이탑 질문입니다. (1) | 미쁘다 | 2025-04-21 |
2692210 | 정보 올림피아드 문제인데.. 풀이 과정이 궁금합니다.(재귀함수) (5) | 물티슈 | 2025-04-20 |
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |