연결리스트 프로그램 종료좀 알려주세요..(+소스추가)
시내
질문 제목 : 프로그램 종료 오류요..질문 요약 :딴 기능은 문제없이 잘되는데 삭제만 하면 자꾸 종료가 되네요..질문 내용 :a, b, c를 차례대로 입력하고 b를 삭제하려고 b를 ㄹ입력하면 프로그램 종료가 되네요
주말내내 씨름해봐도 똑같이만 나와요ㅠㅠ
제발 조금의 도움이라도 좀 주세요..
#include stdio.h
#include stdlib.hstruct node *head;struct node
{
int num;
char data;
struct node *link;
};struct node *insert(struct node *pre, char data1)
{
struct node *i;
i=(struct node*)malloc(sizeof(struct node));
i-data=data1;
if(head==null){
head=i;
i-link=null;
}
else{
i-link=pre-link;
pre-link=i;
}
return (i);
}
struct node printlist()
{
struct node *pt, *pt1;
// char cha; printf(%c , head-data);
pt=head;
while(pt-link!=null){
pt1=pt-link;
pt=pt1;
printf(- %c , pt-data);
}
printf(\n\n);
}
void listdelete()
{
struct node *f, *m, *r;
int i; printf(what do you want to delete? : );
scanf(%d, &i);
printf(\n); r=m-link;
m=f-link;
do{
if(f-data==i){
m=f-link;
head=m;
free(f);
break;
}
else if(m-data==i){
r=m-link;
f-link=m-link;
free(m);
break;
}
f=f-link;
m=m-link;
}while(1);
}void main()
{
int num;
char character;
struct node *pre;
head=pre=null;
do{
printf(1. input character \n);
//printf(2. input between numbers \n);
printf(3. print character in list \n);
printf(4. delete character \n);
printf(5. exit \n);
printf(\n\nselect number : );
scanf(%d, &num);
{
if(num==1)
{
fflush(stdin);
printf(what do you want character? : );
scanf(%c, &character);
pre=insert(pre, character);
printf(\n);
}
/*else if(num==2)
{
if(head==null)
{
printf(not exist number in space \n\n);
}
else
{
betweenlist();
}
}*/
else if(num==3)
{
if(head==null){
printf(not exist number in space \n\n);
}
else{
printlist();
}
}
else if(num==4)
{
if(head==null)
printf(not exist number in space \n\n);
else
listdelete();
}
/* else (num==5);
{
return 0;
}*/
}
} while(num!=5);
}
-
혜린
막무가내로 찾으면 모래사장에서 바늘찾기이고..
F5로 실행해서 디버깅 해보시면, 비정상 종료 시점에 어디서 문제가 생기는지 알려줄거예요.
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2694069 | unsigned 질문입니다. | 힘차 | 2025-05-07 |
2694012 | 전공 비전공자 개발자 (10) | 말글 | 2025-05-07 |
2693984 | 오버로딩이 무엇인가요? (2) | 헛매질 | 2025-05-07 |
2693956 | PlaySound재생이 안됩니다!(C에 음악넣기) | 지존 | 2025-05-06 |
2693928 | &와 *의 사용에 관한 명확한 이해 | 제나 | 2025-05-06 |
2693903 | 반복문 설명좀요 ㅠㅠ (2) | 란새 | 2025-05-06 |
2693869 | stdio.h 는 왜 쓰는건가요? (1) | 큰꽃들 | 2025-05-06 |
2693842 | 포인터 변수의 주소값끼리 더하는 것에 대해서 질문드립니다. (1) | 진솔 | 2025-05-05 |
2693811 | 소수 출력;;;; | 화이트캣 | 2025-05-05 |
2693788 | 이런 함수는 없나요? (3) | 앤드류 | 2025-05-05 |
2693758 | txt파일 불러와서 행렬로 저장 | 큰애 | 2025-05-05 |
2693727 | scanf 오류 문제!! (2) | 큰나래 | 2025-05-04 |
2693704 | 구조체 주소록 문제인데 도와주세요 (2) | 도1도캣 | 2025-05-04 |
2693676 | 열혈강의 c언어 질문입니다 | 하양이 | 2025-05-04 |
2693647 | 12.620000 을요 12.620 으로 어떻게 표현해요? (2) | 파도 | 2025-05-04 |
2693619 | 타이틀 코드.. | 단순드립 | 2025-05-03 |
2693591 | 컴파일 에러에서 질문드립니다 (3) | 게자리 | 2025-05-03 |
2693463 | 동적할당 이용시 fwrite사용을 어떻게 해야하나요..? (10) | 일본어못해요 | 2025-05-02 |
2693387 | 배열문제입니다 수정오류캡쳐했습니다 (6) | 연하얀 | 2025-05-01 |
2693356 | text 입출력 내림차순 질문입니다 ㅠ | 빛글 | 2025-05-01 |