실행에러 잡아주세열!ㅜㅜ
맑은누리
질문 제목 : 실행에러 문제가 있네요질문 내용 : #include stdio.h
#include stdlib.h
#include string.h
int menu(void);
void author_search(struct book *std, int size);
void title_search(struct book *std, int size);
void display(struct book *std, int size);
void save(struct book *std, int size);
void enter(struct book *std, int size);
struct book {
char name[20]; //이름
char title[15]; //
char pub[20]; //
unsigned int date;
unsigned int edition;
};
int main() {
struct book *std=null;
int sel;
int size;
while(1){
sel = menu();
switch(sel){
case 1:
printf(몇 개의 레코드를 입력하시겠습니까? : );
scanf(%d, &size);
fflush(stdin);
enter(std,size);
break;
case 2: author_search(std, size);
break;
case 3: title_search(std, size);
break;
case 4: save(std, size);
break;
case 5: return 0;
}
}
return 0;
}
void enter(struct book *std, int size)
{int i;
std = malloc(sizeof(struct book) * size);
if( std == null ){
printf(동적 메모리 할당 실패\n);
return;
}
for(i=0; isize; i++){
printf(저자이름 : );
gets(std[i].name);
//if(std[i].name==\r) break;
printf(제목: );
gets(std[i].title);
printf(출판사: );
gets(std[i].pub);
printf(출판일: );
scanf(%d,&std[i].date);
printf(판수: );
scanf(%d,&std[i].edition);
fflush(stdin);
}
}
void author_search(struct book *std, int size)
{
int i;
char temp[20];
printf(검색할 저자명을 적어주세요 : );
scanf(%s,temp);
for(i=0; isize; i++) {
if(!strcmp(std[i].name, temp))
{
display(std,size);
}
}
}
void title_search(struct book *std, int size)
{
int i;
char temp[20];
printf(검색할 책제목을 적어주세요 : );
gets(temp);
for(i=0; isize; i++) {
if(!strcmp(std[i].title,temp)==0)
{
display(std,size);
}
}
}
void display(struct book *std, int size)
{
int i;
for(i=0; isize; i++){
printf(저 자 명 = %s\n, std[i].name);
printf(제 목 = %s\n, std[i].title);
printf(출 판 사 = %s\n, std[i].pub);
printf(출 판 일 = %d\n, std[i].date);
printf(판 수 = %d\n, std[i].edition);
}
}
void save(struct book *std, int size)
{
file *fp;
int i;
fp=fopen(c:\\save.txt, w);
if(fp == null)
{
printf(파일 열기 실패);
return;
}
for(i=0; isize;i++) {
fprintf(fp,%s %3s %3s %3d %3d\n, std[i].name,std[i].title,std[i].pub,std[i].date,std[i].edition);
}
fclose(fp);
}
int menu()
{
int a;
printf(1. enter\n);
printf(2. search by author\n);
printf(3. search by title\n);
printf(4. save catalog\n);
printf(5. quit\n);
scanf(%d, &a);
&n/preturn a;
}
1번을 눌러 자료를 실행하면
2번 부분에서 실행 에러가 납니다.
0x004015e5 에 있는 명령이 0x000003c의 메모리를 참조 했습니다. read될수 없습니다 하고 나오네요
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
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 |
2698644 | 1부터 n까지의 합을 구하는데 엄청긴숫자의 합을 구할때는 어떻게 해야하나요? (4) | 슬우 | 2025-06-18 |
2698616 | 다른 함수로 안넘어갑니다..;;; | 도1도캣 | 2025-06-18 |
2698587 | 배열하다 막혀서... (3) | WhiteCat | 2025-06-18 |
2698559 | 문자열을 비우는방법 (2) | 하늘 | 2025-06-18 |
2698528 | 착하고 친절한 선생씌구해염~ㅋㅋ (4) | 옆집언니야 | 2025-06-17 |
2698502 | 자료구조 큐 | 캔서 | 2025-06-17 |
2698477 | 실행화면 배경문의요 | 선아 | 2025-06-17 |
2698430 | 변수의 값이 저장이 않되네요;; (4) | 피네 | 2025-06-16 |
2698404 | C#을 배울려고 하는데 C나 C++을 알아야 하나요 ?? (1) | 신당 | 2025-06-16 |
2698342 | 프로그램 질문점녀 (4) | 데빌의눈물 | 2025-06-16 |
2698318 | 파일 입출력 질문입니다~ (2) | 꽃 | 2025-06-15 |
2698291 | 문자 출력 함수 : putchar, fputc에 관하여. | 으뜸 | 2025-06-15 |