수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

실행에러 잡아주세열!ㅜㅜ

맑은누리

2023.04.01


질문 제목 : 실행에러 문제가 있네요질문 내용 : #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될수 없습니다 하고 나오네요

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2694646 안녕하세요 파일 합치기 함수! (1) 연블루 2025-05-13
2694618 잘몰라서 설명부탁드립니다. scanf 관련 (3) 파라 2025-05-12
2694590 이 코드가 뭐하는 코드일까요? #2 빵순 2025-05-12
2694559 동적할당으로 배열(2차원열)을 만드는데 있어 그걸 함수화시키는데... (1) 늘솔길 2025-05-12
2694532 네트워크에 관하여... (4) 황소자리 2025-05-12
2694503 프로그램 연산 후 바로 종료되는 현상 (6) Judicious 2025-05-11
2694450 while문질문입니다. (1) 허리품 2025-05-11
2694420 C언어 질문할게요(유니코드,자료형,버퍼,캐스트연산자) 은새 2025-05-11
2694370 내일까진데 함수호출 제발 도와주세요!!!!!!!!!11 들찬 2025-05-10
2694339 putchar()의 괄호 안에 int c=10;로 전에 선언된 c를 넣으면 안되는 이유에서 제가 생각한 것이 그 이유가 되는지 확인하고 싶습니다. (3) 미르 2025-05-10
2694316 이 코드 어디가 잘못되었는지 고수분들 ㅠㅠ (2) 나빛 2025-05-10
2694285 언어 공부하는 과정 좀 추천해주세요! (1) 아빠몬 2025-05-09
2694258 카운터.. 질문입니다. (4) 하늘빛눈망울 2025-05-09
2694229 단순한 질문이요 (8) 여름 2025-05-09
2694202 용돈을 가지고 할 수 있는 일을 여러가지로 출력하는 방법 좀 알려주세요! (2) 미나 2025-05-09
2694145 화면깜빡임을 없애고 싶은데요... (1) 어서와 2025-05-08
2694069 unsigned 질문입니다. 힘차 2025-05-07
2694012 전공 비전공자 개발자 (10) 말글 2025-05-07
2693984 오버로딩이 무엇인가요? (2) 헛매질 2025-05-07
2693956 PlaySound재생이 안됩니다!(C에 음악넣기) 지존 2025-05-06
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com