수다닷컴

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

도서관리프로그램 수정기능좀 봐주세요 ㅠ

유리

2023.04.01

도서관리프로그램을 만들려 하는데.....수정함수에서 계속 에러가 발생하네요 ㅠㅠㅠ질문 요약 :수정함수를 짜봣는데.......좀고처주시면 감사하겠습니다 ㅠ저런식이아니면 예로 소스점 부탁드립니다ㅠ질문 내용 :
#include stdio.h
#include string.h
#define MAX 100
struct book_struct
{
char name[20];
char writer[20];
int year;
char company[20];
}book[MAX];
int top=0;
void input(void); //도서입력 함수
void output(void); //도서출력 함수
void search(void); //도서검색 함수
void re(void);
int main(void)
{
while(1)
{
int key;
printf(***************수원대 도서관리 프로그램**************\n);
printf( 1.도서추가 \n);
printf( 2.도서출력 \n);
printf( 3.도서검색 \n);
printf( 4.도서수정 \n);
printf( 5.종료 \n);
printf(***************해당번호를 입력 하십시오**************\n);
printf(입력란-);
scanf(%d,&key);
if(key==1)
{
input();
}
else if(key==2)
{
output();
}
else if(key==3)
{
search();
}
else if(key==4)
{
re();
}
else if(key==5)
{
printf(*************************종료************************\n);
printf(********************안녕히 가세요^^******************\n);
return 0;
}
else
{
printf(잘못된입력 입니다\n);
}
}
}

void input(void)
{

FILE * file = fopen(libray.txt, at);

printf(추가 하실 책 이름은: );
scanf(%s, book[top].name);
printf(추가 하실 책의 저자: );
scanf(%s, book[top].writer);
printf(추가 하실 책의 출판년도: );
scanf(%d, &book[top].year);
printf(추가 하실 책의 출판사: );
scanf(%s, book[top].company);

fprintf(file, %s\n, book[top].name);
fprintf(file, %s\n, book[top].writer);
fprintf(file, %d\n, book[top].year);
fprintf(file, %s\n, book[top].company);
fclose(file);
printf(*************도서목록에 추가 되었습니다^^************\n);
}

void output(void)
{
FILE* file =fopen(libray.txt, rt);
int i=0;
for(top=0;top20;top++)
{

fscanf(file, %s\n,book[top].name);
fscanf(file, %s\n,book[top].writer);
fscanf(file, %d\n,&book[top].year);
fscanf(file, %s\n,book[top].company);
if(!*book[top].name) break;
}
for(i=0;itop;i++)
{
printf(*****************************************************\n);
printf(도서명:%s\n, book[i].name);
printf(저자:%s\n, book[i].writer);
printf(출판년도:%d\n, book[i].year);
printf(출판사:%s\n, book[i].company);
}
fclose(file);
}
void search(void)
{
FILE* file =fopen(libray.txt, rt);

int i;
char name[20];
char writer[20];
int year;
char company[20];

for(top=0;top200;top++)
{
fscanf(file, %s\n,book[top].name);
fscanf(file, %s\n,book[top].writer);
fscanf(file, %d\n,&book[top].year);
fscanf(file, %s\n,book[top].company);
if(!*book[top].name) break;
}
printf(무엇으로 검색 하시겠습니까?\n);
printf(1.도서명 2.저자 3.출판년도 4.출판사\n);
printf(원하시는 기능의 번호를 입력 하시오 :);
scanf(%d,&i);switch(i)
{
case 1:
printf(검색 하실 책은 이름을 입력하시오: );
scanf(%s, name);

&nbs
for(top=0; top200; top++)
{

if(strcmp(book[top].name,name)==0)
{
printf(**************검색 하신 책의 정보 입니다*************\n);
printf(도서명:%s\n, book[top].name);
printf(저자:%s\n, book[top].writer);
printf(출판년도:%d\n, book[top].year);
printf(출판사:%s\n, book[top].company);
}

}
break;
case 2:
printf(검색 하실 저자를 입력하시오: );
scanf(%s, writer);

for(top=0; top200; top++)
{

if(strcmp(book[top].writer,writer)==0)
{
printf(**************검색 하신 책의 정보 입니다*************\n);
printf(도서명:%s\n, book[top].name);
printf(저자:%s\n, book[top].writer);
printf(출판년도:%d\n, book[top].year);
printf(출판사:%s\n, book[top].company);
}

}
break;
case 3:
printf(검색 하실 출판년도 입력하시오: );
scanf(%d, &year);

for(top=0; top200; top++)
{

if(book[top].year==year)
{
printf(**************검색 하신 책의 정보 입니다*************\n);
printf(도서명:%s\n, book[top].name);
printf(저자:%s\n, book[top].writer);
printf(출판년도:%d\n, book[top].year);
printf(출판사:%s\n, book[top].company);
}

}
break;
case 4:
printf(검색 하실 출판사를 입력하시오: );
scanf(%s,company );

for(top=0; top200; top++)
{

if(strcmp(book[top].company,company)==0)
{
printf(**************검색 하신 책의 정보 입니다*************\n);
printf(도서명:%s\n, book[top].name);
printf(저자:%s\n, book[top].writer);
printf(출판년도:%d\n, book[top].year);
printf(출판사:%s\n, book[top].company);
}

}
break;
default:
printf(********************해당 번호가 없습니다*******************\n);
}
fclose(file);
}

void re(void)//수정함수여기입니다.....
{
FILE* file =fopen(libray.txt, at);
char name[20];
char ch[20];
printf(수정하실 책의 이름을 입력하시오: );
scanf(%s,&name);

for(top=0;top200;top++)
{
fscanf(file, %s\n,book[top].name);
fscanf(file, %s\n,book[top].writer);
fscanf(file, %d\n,&book[top].year);
fscanf(file, %s\n,book[top].company);
if(!*book[top].name) break;
}

for(top=0; top200; top++)
{if(strcmp(book[top].name,name)==0)
{

printf(도서명:%s\n, book[top].name);
printf(저자:%s\n, book[top].writer);
printf(출판년도:%d\n, book[top].year);
printf(출판사:%s\n, book[top].company);
printf(수정하실 도서명을 입력하시오!);
scanf(%s,&ch);
book[top].name=ch;이부분에서 에러가 뜨네요....제가 하긴햇는데 수정함수를 이런식으로 짜는게 맞는지도 모르겟어요..
fprintf(file,%d\n,book[top].name);}

}
fclose(file);
}

신청하기





COMMENT

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

  • 민들레

    ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

  • 마징가

    포인터를 이용해보세요'

번호 제 목 글쓴이 날짜
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
2693928 &와 *의 사용에 관한 명확한 이해 제나 2025-05-06
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

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