c언어 리스트 함수에대해서 질문드립니다. 왜 오류가 뜨는지 모르겠습니다.
작약
질문 제목 : c언어 리스트 함수에대해서 질문드립니다. 왜 오류가 뜨는지 모르겠습니다.질문 요약 :오류가 100가 넘어가는데 어디서부터 잘못된건지 모르겠습니다.....
문법에서 뭔가 잘못된건가요? 도저히 어디가 문제인지 찾질못하여 질분드립니다. 부탁드립니다.질문 내용 :
listp.h 파일입니다.
struct node
{
int data;//노드 내부의 실제 데이터 또는 레코드
struct node* next;//next가 가리키는 것은 node 타입, 즉 자기 자신 타입
};//구조체에 node라는 새로운 타입명 부여
typedef struct node node;
typedef node* nptr; //nptr 타입이 가리키는 것은 node 타입
struct listtype
{
int count;//리스트 길이를 추적
nptr head;//헤드 포인터로 리스트 전체를 대변함
};
typedef struct listtype listtype;
void insert(listtype *lptr, int position, int item);//해당 위치에 데이터를 삽입
void delete(listtype *lptr, int position); //해당 위치 데이터를 삭제
void retrieve(listtype *lptr, int position, int *itemptr);//찾은 데이터를 *itemptr에 넣음
void init(listtype *lptr);//초기화
int isempty(listtype *lptr);//비어있는지 확인
int length(listtype *lptr);
----------------------------------------------------------------------------------------------
listp.c입니다.
#include stdio.h
#include stdlib.h
#include listp.h
void insert(listtype *lptr, int position, int item)//해당 위치에 데이터를 삽입
{
nptr temp;
if((position (lptr-count+1)) || (position1))
printf(position out of range);
else
{
nptr p=(node *)malloc(sizeof(node));
p-data = item;
if(position ==1)
{
p-next = lptr-head;
lptr-head = p;
}
else
{
temp = lptr-head;
for(int i=1; i(position-1);i++)
temp=temp-next;
p-next = temp-next;
temp-next = p;
}
lptr-count ++;
}
}
void delete(listtype *lptr, int position) //해당 위치 데이터를 삭제
{
if(isempty(lptr))
printf(deletion on empty list);
else if (position (lptr-count) || (position1))
printf(position out of range);
else
{
if(position==1)
{
nptr p=lptr-head;
lptr-head=lptr-head-next;
}
else
{
nptr temp = lptr-head;
for(int i=1; i (position-1) ; i++)
temp = temp-next;
nptr p= temp-next;
temp-next = p-next;
}
lptr-count --;
free (p);
}
}
void retrieve(listtype *lptr, int data, int *itemptr)
{int i=1;
nptr tmp=lptr-head;
while(tmp!=null)
{
if(position==tmp-data)
break;
i++;
tmp=tmp-next;
}
if(ilptr-count)
{
printf(the data %d is not exists\n,position);
}
else
{itemptr=&tmp-data;
&nbbr /printf(the data %d is at position %d in the list\n,position,i);
}
}//찾은 데이터를 *itemptr에 넣음
void init(listtype *lptr)//초기화
{
lptr-count=0;
lptr-head=null;
}
int isempty(listtype *lptr)//비어있는지 확인
{
return (lptr-count ==0);
}
int length(listtype *lptr){
}
--------------------------------------------
main.c 입니다
#includestdio.h
#includestdlib.h
#includetime.h
#include listp.h
int main(void)
{
nptr p=(node *)malloc(sizeof(node));
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
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 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |