C언어 물품관리 프로그램 질문이요~
즐겨찾기
질문 제목 : 물품관리 프로그램을 짜는 중에 텍스트 파일에 저장된 데이터를 화면에 띄울수가 없어요...;;
1. 텍스트 파일에 저장한 데이터를 검색하는 기능을 만들게 조언과 도움 부탁드립니다...!!
질문 내용 :
제가 현재... 아직까지도.... 물품관리 프로그램을 만들고 있습니다.
근데 친구의 도움으로 텍스트 파일을 열고 그안에 내용을 저장하는 것 까진 완성을 했습니다.
결국 2개 완성한 거죠...(할게 8번까지 있는데....ㅠ) 그런데..!!!!
검색이 되질 않습니다....ㅠㅠ 결국 질문은...!!
1. 텍스트 파일에 저장한 데이터를 검색하는 기능을 만들게 조언과 도움 부탁드립니다...!!
밑에 소스 올립니다....
(수정)그리고 밑에 결과 사진도올려봅니다...
1개는 메뉴
1개는 메뉴에서 2번을 눌렀을때 뜨는 결과
#include stdio.h
#include stdlib.h
#include string.h
char name[100];
char state[100];
int num;
int money;
int figure;
int i=0;
int count=0;
typedef struct Goods_tag
{
char name[100];
char state[100];
int num;
int money;
int figure;
}Goods_tag;
Goods_tag Goods[100];
void Goods_Resist()
{
int x;
while(1)
{
printf(\n);
printf(《1. 물품 등록 》\n);
printf(==================\n);
printf(ο물품 종류: );
scanf(%s, Goods[i].state);
printf(\n);
printf(ο물품 이름: );
scanf(%s, Goods[i].name);
printf(\n);
printf(ο물품 번호: );
scanf(%d, &Goods[i].num);
printf(\n);
printf(ο물품 가격: );
scanf(%d, &Goods[i].money);
printf(\n);
printf(ο물품 갯수: );
scanf(%d, &Goods[i].figure);
printf(\n);
i++;
count++;
printf(1.계속 2.메뉴 \n);
printf(번호를 선택하세요.: );
scanf(%d, &x);
system(cls);
if(x==1)
continue;
else if(x==2)
break;
else
printf(잘못 입력하셨습니다.\n);
}
}
void Goods_Search()
{
char arr[]=Goods_mage.txt;
FILE *f;
f = fopen(Goods_manage.txt,r);
if(f==NULL)
{
printf(원본 파일 %s를(을) 열 수 없습니다. \n, arr);
exit(1);
}
fclose(f);
}
void Goods_save()
{
int i;
FILE *f;
f = fopen(Goods_manage.txt,a);
if(f==NULL)
{
printf(파일이 열리지 않습니다.\n);
exit(1);
}
for(i=0;icount;i++)
{
fprintf(f,%s \t %s \t %d \t %d \t %d \t \n,Goods[i].state,Goods[i].name,Goods[i].num,Goods[i].money,Goods[i].figure);
}
fclose(f);
}
void menu()
{
int x;
printf(\n);
printf(┏━━━━━━━━━━━━━━━━━━━━┓ \n);
printf(┃ GS_24 물품관리프로그램 ┃ \n);
printf(┗━━━━━━━━━━━━━━━━━━━━┛\n);
printf(┃ 1.물품 등록 ┃\n);
printf(┃ ┃\n);
printf(┃ 2.물품 검색 ┃\n);
printf(┃ ┃\n);
printf(┃ 3.물품 삭제 ┃\n);
printf(┃ ┃\n);
printf(┃ 4.풀품 판매 ┃\n);
printf(┃ ┃\n);
printf(┃ 5.물품 폐기 ┃\n);
printf(┃ ┃\n);
printf(┃ 6.재고 확인 ┃\n);
printf(┃ ┃\n);
printf(┃ 7.발 주 ┃\n);
printf(┃ ┃\n);
printf(┃ 8.프로그램종료 ┃\n);
printf(┗━━━━━━━━━━━━━━━━━━━━┛\n);
printf(실행할 메뉴를 선택하시오. : );
scanf(%d, &x);
system(cls);
switch(x)
{
case 1:
Goods_Resist();
Goods_save();
break;
case 2:
Goods_Search();
case 8:
printf(\n);
printf(프로그램을 종료합니다.\n);
printf(\n);
exit(1);
}
}
int main()
{
while(1)
{
menu();
}
이게 메뉴 입니다.
이게 2번을 눌렀을때 바로 뜨는 화면 입니다... ㅠㅠ 전 텍스트 파일에 저장된걸 출력하려 했는데 말이죠...;;