도서관리프로그램 수정기능좀 봐주세요 ㅠ
유리
도서관리프로그램을 만들려 하는데.....수정함수에서 계속 에러가 발생하네요 ㅠㅠㅠ질문 요약 :수정함수를 짜봣는데.......좀고처주시면 감사하겠습니다 ㅠ저런식이아니면 예로 소스점 부탁드립니다ㅠ질문 내용 :
#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);
}
-
민들레
ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
-
마징가
포인터를 이용해보세요'
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2685477 | 소수점이하 출력하는거요 | 널위해 | 2025-02-18 |
2685449 | printf배우고있는데요 궁금한게있어요 (8) | 꽃큰 | 2025-02-18 |
2685393 | c언어 질문이요.... | 붕붕 | 2025-02-18 |
2685365 | 윈도우7에서 visual studio c++6.0 (1) | 빛길 | 2025-02-17 |
2685317 | segmentation fault가 나요 | 가람 | 2025-02-17 |
2685292 | 다중스택질문 | 올해1살 | 2025-02-17 |
2685231 | C언어와 닷넷에 대해서 질문!! (2) | 설아 | 2025-02-16 |
2685206 | VisualBasic 과 DEV++ 의 장단점과 만든 파일 호환 가능하나요? | 에드워드 | 2025-02-16 |
2685154 | 배열 크기조절 | 해찬솔 | 2025-02-15 |
2685124 | 수정이거 제가 뭐가 잘못한거죠 ? | 아이돌 | 2025-02-15 |
2685096 | 포인터의 고수분들 모두 보세요!! 제발 ㅠ_ㅠ 헷갈려헷갈려..갈려헷.. (7) | 치킨마루 | 2025-02-15 |
2685045 | 전처리기 질문 | 치에미 | 2025-02-14 |
2685016 | 오류 좀 확인해 주시면 감사하겠습니다 | 초코맛사탕 | 2025-02-14 |
2684917 | 알고리즘을 이용한 행렬의 전치// 문제다운 문제네요. | 뿡뿡 | 2025-02-13 |
2684868 | 양방향 연결리스트에서 실행도중 죽는 이유좀 찾아주세요. (2) | 예다움 | 2025-02-13 |
2684844 | 시계프로그램인데 도저히 모르겠어요ㅠ (1) | 비내리던날 | 2025-02-12 |
2684812 | 레포트좀도와주세요ㅠㅠ (2) | 갈매빛 | 2025-02-12 |
2684780 | 채팅창 흉내내보려고하는데요 ㅜ.ㅜ (1) | 바름 | 2025-02-12 |
2684729 | 내일 시험인데 메모리 그리는것좀 도와주세요 ㅠ (1) | 상처주지마 | 2025-02-11 |
2684701 | 버퍼 관련 질문 3가지 (이전거랑 달라요) | 한국녀 | 2025-02-11 |