실행에러 잡아주세열!ㅜㅜ
맑은누리
질문 제목 : 실행에러 문제가 있네요질문 내용 : #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될수 없습니다 하고 나오네요
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
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 |
2691483 | 파일 오픈시 에러 질문드립니다. (2) | 호습다 | 2025-04-14 |
2691450 | [visual c++ 툴]기초 질문 (3) | 해긴 | 2025-04-13 |