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));
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2699304 | [기초]아직 안주무시는분 계신가요..?포인터배열? 좀 도와주세요. | 놀리기 | 2025-06-24 |
2699272 | printf() 함수이용해서 프로그램 만들기 질문요! (5) | 다가 | 2025-06-24 |
2699221 | PUSH와 POP코드를 더 간단하게 어떻게 해야할까요? | 파라미 | 2025-06-24 |
2699192 | 설치오류가 자꾸 나요 한번봐주세여~ (1) | 소녀틳향기 | 2025-06-23 |
2699161 | for loop안에 있는 if문 (9) | Orange | 2025-06-23 |
2699105 | 링크더리스트 이전 링크값 출력함수. | 꼬꼬마 | 2025-06-23 |
2699078 | 정수를 한자리씩 배열에 담는 법은 어떻게 하나요.. (4) | 귀염포텐 | 2025-06-22 |
2699024 | C언어 공부하려는데 도와주세요!!! (2) | 달님 | 2025-06-22 |
2698994 | 날짜 계산하는 C 코드 짜고 있는데 꽉 막혀서 질문드립니다.. (6) | 별 | 2025-06-22 |
2698967 | 파일삭제 윈도우 폴더까지 접근하게하는 함수가 뭔가요 (2) | 샤인 | 2025-06-21 |
2698938 | c언어 메모리질문 (3) | 나래 | 2025-06-21 |
2698909 | 서비스 요청 고객 관리 프로그램 짜는것좀 도와주세요ㅜㅜ (4) | 궁수자리 | 2025-06-21 |
2698882 | 프로그래밍좀 짜주세요 (3) | 황예 | 2025-06-21 |
2698855 | 카프-라빈 알고리즘 코딩 분석좀 도와주세요.. | 꽃봄 | 2025-06-20 |
2698829 | 학점계산기 (7) | MyWay | 2025-06-20 |
2698782 | 기초적인 함수 질문이요ㅠㅠㅠㅠ | 내담 | 2025-06-20 |
2698749 | 프로그램 짜던 도중 패닉입니다...ㅜ | 파랑 | 2025-06-19 |
2698719 | 조건부컴파일 질문입니다.~ (2) | 큐트 | 2025-06-19 |
2698693 | 재귀 함수 에러 | 바닐라 | 2025-06-19 |
2698673 | 고민이있는데 들어좀주세요!! (1) | 초코맛캔디 | 2025-06-19 |