질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

뭐가 잘못된거죠?

작성자 정보

  • 장광익 작성
  • 작성일

컨텐츠 정보

본문

c프로그램을 짰는데 애러가 나는데

vc에선 애러가 안나고 잘돌아가는데

왜gcc로 하면 애러가 나죠? 모가 문제인지. 설명좀..

수정해주심 더욱 감사하고요 gcc초보자 입니다.읔..

#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <malloc.h>
#include <process.h>

typedef struct video // 비디오 구조체
{
 int    ivCode; // 비디오등록시 코드는 0 부터자동으로 증가한다.
 char * pvTitle; // 비디오 제목
 int    ivkind; // 비디오 장르
 int    ivRent; // 비디오가 대여중인지 판별
 int    ivRentCount; // 비디오 대여 횟수
}VI;

typedef struct client // 고객 구조체
{
 char * pcName; // 고객 이름
 char * pcAddr; // 고객 주소
 char * pcTel; // 고객 전화번호 입력시 수정 불가
 int    icAge; // 고객 나이
 char   ccSex; // 고객 성별
}CL;

typedef struct rent // 대여 구조체
{
 int    irCode; // 대여 비디오 코드
 char * prTel; // 고객의 전화번호
 int   irDay; // 대여 일자
 int   irReturn; // 반납 일자
}RE;

//고객 함수 (Client 앞글자 C를따서 고객함수 앞에 C를 붙혔다)
int Cinput(CL * client[],int icCount); // 비디오 등록 함수
int CDelSearch(CL * client[],int icCount); // 널번지 서치 함수
void CNodeInput(CL * client[],int icDelSearch,int i,char *cTelStore); // 실질적인 데이터 입력 함수
int CSearch(CL * client[],int icCount,char * ctitle); // 고객 정보 찾는함수
void CNodePrint(CL * pClient); // 고객 정보 출력 함수
void CDelete(CL * client[],int icSearch); // 정보 수정시 프리 함수
void CFileSave(CL * client[],int icCount); // 데이터를 파일로 저장하는 함수
int CFileLoad(CL * client[],int icCount); // 데이터를 로드하는 함수
void CNodePrintII(CL * client[],int icCount); // 전체 고객 정보를 출력하는 함수


//비디오 함수(Video 앞글자 V를따서 비디오함수 앞에 V를 붙혔다)
int Vinput(VI * video[],int ivCount); // 비디오 등록 함수
int VDelSearch(VI * video[],int ivCount); // 비디오 널 번지 찾는 함수
void VNodeInput(VI * video[],int ivDelSearch,int i); // 실질적인 데이터 입력 함수
int VSearch(VI * video[],int ivCount,char * vtitle); // 비디오 검색 함수
void VNodePrint(VI * pVideo); // 비디오 정보 출력함수
void VFileSave(VI * video[],int ivCount); // 데이타 파일 저장 함수
int VFileLoad(VI * video[],int ivCount); // 데이타 파일 로드함수
void VNodePrintII(VI * video[],int ivCount); // 비디오 정보를 모두 출력하는 함수
void VNodePrintIII(VI * video[],int ivCount); // 대여중인 비디오를 출력하는 함수


//대여 함수 (Rent 앞글자 R를따서 대여함수 앞에 R를 붙혔다)
int Rrent(RE * rent[],CL * client[],VI * video[],int irCount,int icCount,int ivCount); // 대여 함수
int RTelSearch(CL * client[],int icCount); // 등록된 고객인지 전화번호로 검색하는 함수
void RrentPrint(RE * rent[],CL * client[],VI * video[],int irCount,int icCount,int ivCount); //대여 정보 출력
void RFileSave(RE * rent[],int irCount); // 대여정보를 저장하는 함수
int RFileLoad(RE * rent[],int irCount); // 대여정보를 로드하는 함수
void RReturn(RE * rent[],CL * client[],VI * video[],int irCount,int icCount,int ivCount);//반납함수
void RNodeFree(RE * rent[],int irSearch); // 반납하기전 프리를 시켜준후 반납을 하면 내용을 수정

#define VIDEOMAX 500
#define CLIENTMAX 500
#define RENTMAX 500

#define SAFE_FREE(a) { free(a); a = NULL; };
void main()
{
 VI * video[VIDEOMAX];
 CL * client[CLIENTMAX];
 RE * rent[RENTMAX];

 char cResult;
 char cResultII;
 char cTelStore[20];
 int ivCount = 0;  // 비디오 인덱스
 int icCount = 0;  // 고객 인덱스
 int irCount = 0;  // 대여 인덱스
 int icSearch;
 icCount = CFileLoad(client,icCount); // 시작시 고객파일을 자동으로 로드
 ivCount = VFileLoad(video,ivCount); // 시작시 비디오파일을 자동으로 로드
 irCount = RFileLoad(rent,irCount); // 시작시 대여파일을 자동으로 로드
 do
 {
  system("cls");
  printf(" Video Shop ver -1.0-                                      program by      ik ");
  printf("┏━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┓ ");
  printf("┃   대 여 관 리  ┃   고 객 관 리    ┃  비 디 오 관 리  ┃    종     료   ┃ ");
  printf("┣━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━┫ ");
  printf("┃1. 대 여 관 리  ┃2. 고객 등록      ┃5.비디오 등록     ┃ 0. 종     료   ┃ ");
  printf("┃                ┃3. 고객 정보 출력 ┃6.비디오 정보 출력┃                ┃ ");
  printf("┃                ┃4. 고객 정보 수정 ┃7.대여중비디오출력┃                ┃ ");
  printf("┃                ┃                  ┃                  ┃                ┃ ");
  printf("┃                ┃                  ┃                  ┃                ┃ ");
  printf("┗━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━┛ ");
  printf(" 메뉴를 선택하세요 : [ ]");
  cResult=getche();

  switch(cResult)
  {
   case '1':
    printf(" ▶ 대 여 관 리 ─────────────────────────────── ");
    do{
     printf(" 1. 비디오 대여, 2. 비디오 반납, 3. 고객 대여정보 출력 : [ ]");
     cResultII=getche();
     printf(" ");
    }while(cResultII !='1' && cResultII !='2' && cResultII !='3');
    if(cResultII == '1')
    {
     irCount = Rrent(rent,client,video,irCount,icCount,ivCount);
    }
    if(cResultII == '2')
    {
     RReturn(rent,client,video,irCount,icCount,ivCount);
     getch();
    }
    if(cResultII == '3')
    {
     RrentPrint(rent,client,video,irCount,icCount,ivCount);
     getch();
    }
    break;
   case '2':
    printf(" ▶ 고 객 등 록 ─────────────────────────────── ");
    icCount = Cinput(client,icCount);
    break;
   case '3':
    printf(" ▶ 고 객 정 보 출 력──────────────────────────── ");
    do{
     printf(" 1. 개 인 검 색, 2. 전 체 출 력 : [ ]");
     cResultII=getche();
     printf(" ");
    }while(cResultII !='1' && cResultII !='2');

    if(cResultII=='1')
    {
     icSearch = CSearch(client,icCount," ☞ 검 색 할  이 름 : ");
     if(icSearch == -1)
     {
      printf(" ──검 색  결 과 가  없 습 니 다!!!!──");
     }
     else
     {
      system("cls");
      CNodePrint(client[icSearch]);
     }
    }
    else
    {
     CNodePrintII(client,icCount);
    }
    getch();
    break;
   case '4':
    printf(" ▶ 고 객 정 보 수 정──────────────────────────── ");
    icSearch = CSearch(client,icCount," ☞ 수 정 할  이 름 : ");
    if(icSearch == -1)
    {
     printf(" ──검 색  결 과 가  없 습 니 다!!!!──");
     getch();
    }
    else
    {
     printf(" ");
     strcpy(cTelStore,client[icSearch]->pcTel);
     CDelete(client,icSearch);
     CNodeInput(client,icSearch,2,cTelStore);
    }
    break;
   case '5':
    printf(" ▶ 비 디 오 등 록 ───────────────────────────── ");
    ivCount = Vinput(video,ivCount);
    break;
   case '6':
    printf(" ▶ 비 디 오 정 보 출 력────────────────────────── ");
    do{
     printf(" 1. 검 색 출 력, 2. 전 체 출 력 : [ ]");
     cResultII=getche();
     printf(" ");
    }while(cResultII !='1' && cResultII !='2');

    if(cResultII=='1')
    {
     icSearch = VSearch(video,ivCount," ☞ 검 색 할  비 디 오 : ");
     if(icSearch == -1)
     {
      printf(" ──검 색  결 과 가  없 습 니 다!!!!──");
     }
     else
     {
      system("cls");
      VNodePrint(video[icSearch]);      
     }
    }
    else
    {
     VNodePrintII(video,ivCount);
    }
    getch();
    break;
   case '7':
    VNodePrintIII(video,ivCount);
    getch();
    break;
   case '8':
    break;
   case '9':
    break;
   case '0':
    break;
  }
 }while(cResult!='0');
 CFileSave(client,icCount); // 종료시 모든 파일을 자동으로 저장
 VFileSave(video,ivCount);
 RFileSave(rent,irCount);
 printf(" ");
}

//####################################고객 관리 함수 시작###########################################33

int Cinput(CL * client[],int icCount)
{
 int icDelSearch;
 if(icCount >= CLIENTMAX)
 {
  printf("──경고!!! 더이상 입력할 공간이 없습니다.── ");
  return icCount;
 }

 icDelSearch = CDelSearch(client,icCount);
 CNodeInput(client,icDelSearch,1,NULL);

 if(icDelSearch == icCount)
 {
  return ++icCount;
 }
 else
 {
  return icCount;
 }
}

int CDelSearch(CL * client[],int icCount)
{
 int i;
 for(i=0;i {
  if(client[i] == NULL)
  {
   return i;
  }
 }
 return icCount;
}

void CNodeInput(CL * client[],int icCount,int i,char *cTelStore)
{
 char temp[256];
 char sex;
 int k;
 
 client[icCount] = (CL *)malloc(sizeof(CL));

 printf("이       름 : ");
 gets(temp);
 client[icCount]->pcName = (char *)malloc(strlen(temp)+1);
 strcpy(client[icCount]->pcName,temp);

 printf("주       소 : ");
 gets(temp);
 client[icCount]->pcAddr = (char *)malloc(strlen(temp)+1);
 strcpy(client[icCount]->pcAddr,temp);

 if(i == 1)
 {
  printf("전       화 : ");
  gets(temp);
  client[icCount]->pcTel = (char *)malloc(strlen(temp)+1);
  strcpy(client[icCount]->pcTel,temp);
  for(k=0;k  {
   do
   { 
    if(strcmp(temp,client[k]->pcTel)==0)
    {
     printf("이미 등록된 전화번호입니다. ");
     printf("전       화 : ");
     gets(temp);
    }
   }while(strcmp(temp,client[k]->pcTel)==0);
  }
 }
 else
 {
  printf("전       화 : 수정 불 가능!! ");
  client[icCount]->pcTel = (char *)malloc(strlen(cTelStore)+1);
  strcpy(client[icCount]->pcTel,cTelStore);
 }
 do{
  printf("성       별(남자 1, 여자 2) : ");
  sex=getche();
  printf(" ");
 }while(sex !='1' && sex !='2');
 if(sex=='1'){client[icCount]->ccSex='M';}
 else{client[icCount]->ccSex='W';}
 
 printf("나       이 : ");
 scanf("%d",&client[icCount]->icAge);
 fflush(stdin);
}

int CSearch(CL * client[],int icCount,char * ctitle)
{
 int i;
 char temp[256];

 printf(ctitle);
 gets(temp);

 for(i=0;i {
  for(i = 0;i  {
   if(client[i] != NULL)
    if(strcmp(temp,client[i]->pcName) == 0)
    {
     return i;
    }
  }
 }
 return -1;
}

void CNodePrint(CL * pClient)
{
  printf("   ──고 객  개 인  정 보── ");
  printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
  printf("    이  름 : %s       나   이 : %d         성    별 : %c ",pClient->pcName,pClient->icAge,pClient->ccSex);
  printf("    주  소 : %s       전화번호 : %s ",pClient->pcAddr,pClient->pcTel);
  printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
}

void CNodePrintII(CL * client[],int icCount)
{
 int i,Count=0;
 system("cls");
 for(i=0;i {
  if(client[i] != NULL)
  {
   printf("─────────────────────────────────────── ");
   printf("    이  름 : %s       나   이 : %d       성    별 : %c ",client[i]->pcName,client[i]->icAge,client[i]->ccSex);
   printf("    주  소 : %s  전화번호 : %s ",client[i]->pcAddr,client[i]->pcTel);
   printf("─────────────────────────────────────── ");
   Count++;
   if(Count%5 == 0)
   {
    printf("                                                             Press Any Key");
    getch();
    system("cls");
   }
  }
 }
 if(Count%5 !=0)
 {
 printf("                                                             Press Any Key");
 }
}

void CDelete(CL * client[],int icSearch)
{
 free(client[icSearch]->pcName);
 free(client[icSearch]->pcAddr);
 free(client[icSearch]->pcTel);

 SAFE_FREE(client[icSearch]);
}

void CFileSave(CL * client[],int icCount)
{
 FILE *fp;
 int i;

 fp=fopen("Client.txt","w");
 for(i=0;i {
  if(client[i] != NULL)
  {
   fprintf(fp,"%s ",client[i]->pcName);
   fprintf(fp,"%s ",client[i]->pcAddr);
   fprintf(fp,"%s ",client[i]->pcTel);
   fprintf(fp,"%c %d ",client[i]->ccSex,client[i]->icAge);
  }
 }
 fclose(fp);
}

int CFileLoad(CL * client[],int icCount)
{
 FILE * fp;
 char temp[256];
 
 fp = fopen("Client.txt","r");
 if (fp == NULL)
 {
  printf(" 파일이 없습니다.");
  return icCount;
 }
 
 while(1)
 {
  fgets(temp,256,fp);
  if (feof(fp))
  {
   break;
  }
  
  client[icCount] = (CL *)malloc(sizeof(CL));
  
  client[icCount]->pcName = (char *)malloc(strlen(temp));
  strncpy(client[icCount]->pcName,temp,strlen(temp)-1);
  client[icCount]->pcName[strlen(temp)-1] = '';
  
  fgets(temp,256,fp);
  client[icCount]->pcAddr = (char *)malloc(strlen(temp));
  strncpy(client[icCount]->pcAddr,temp,strlen(temp)-1);
  client[icCount]->pcAddr[strlen(temp)-1] = '';
  
  fgets(temp,256,fp);
  client[icCount]->pcTel = (char *)malloc(strlen(temp));
  strncpy(client[icCount]->pcTel,temp,strlen(temp)-1);
  client[icCount]->pcTel[strlen(temp)-1] = '';
  
  fscanf(fp,"%c %d",&client[icCount]->ccSex,&client[icCount]->icAge);
  fgets(temp,256,fp);
  icCount++;
 }
 return icCount;
}

//####################################비디오관리 함수 시작###########################################33

int Vinput(VI * video[],int ivCount)
{
 int ivDelSearch;
 if(ivCount >= VIDEOMAX)
 {
  printf("──경고!!! 더이상 입력할 공간이 없습니다.── ");
  return ivCount;
 }

 ivDelSearch = VDelSearch(video,ivCount);
 VNodeInput(video,ivDelSearch,1);

 if(ivDelSearch == ivCount)
 {
  return ++ivCount;
 }
 else
 {
  return ivCount;
 }
}

int VDelSearch(VI * video[],int ivCount)
{
 int i;
 for(i=0;i {
  if(video[i] == NULL)
  {
   return i;
  }
 }
 return ivCount;
}

void VNodeInput(VI * video[],int ivCount,int i)
{
 char temp[256];
 
 video[ivCount] = (VI *)malloc(sizeof(VI));

 printf("제       목 : ");
 gets(temp);
 video[ivCount]->pvTitle = (char *)malloc(strlen(temp)+1);
 strcpy(video[ivCount]->pvTitle,temp);

 printf("비디오 코드 : %d (자동입력) ",ivCount);
 video[ivCount]->ivCode = ivCount;

 printf("장 르(1.SF, 2.액션, 3.멜로, 4.만화, 5.에로) : ");
 scanf("%d",&video[ivCount]->ivkind);
 fflush(stdin);
 if(i==1){video[ivCount]->ivRent=1;}
 else{video[ivCount]->ivRent=0;}
 video[ivCount]->ivRentCount=0;
}

int VSearch(VI * video[],int ivCount,char * vtitle)
{
 int i;
 char temp[256];

 printf(vtitle);
 gets(temp);

 for(i=0;i {
  for(i = 0;i  {
   if(video[i] != NULL)
    if(strcmp(temp,video[i]->pvTitle) == 0)
    {
     return i;
    }
  }
 }
 return -1;
}

void VNodePrint(VI * pVideo)
{
  printf("   ──비 디 오  정 보── ");
  printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
  printf("    제       목 : %s ",pVideo->pvTitle);
  printf("    코       드 : %d ",pVideo->ivCode);
  if(pVideo->ivkind == 1)
  {
   printf("    장       르 : SF ");
  }
  if(pVideo->ivkind == 2)
  {
   printf("    장       르 : 액션 ");
  }
  if(pVideo->ivkind == 3)
  {
   printf("    장       르 : 멜로 ");
  }
  if(pVideo->ivkind == 4)
  {
   printf("    장       르 : 만화 ");
  }
  if(pVideo->ivkind == 5)
  {
   printf("    장       르 : 에로 ");
  }
  printf("    대 여 횟 수 : %d ",pVideo->ivRentCount);
  if(pVideo->ivRent==1)
  {
   printf("    현 제 재 고 : 있  음(대여중이지 않음) ");
  }
  else
  {
   printf("    현 제 재 고 : 대여중 ");
  }
  printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
}
void VNodePrintII(VI * video[],int ivCount)
{
 int i,Count=0;
 system("cls");
 printf("   ──비 디 오  정 보── ");
 for(i=0;i {
  printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
  printf("    제      목 : %s",video[i]->pvTitle);
  printf("    코      드 : %d ",video[i]->ivCode);
  if(video[i]->ivkind == 1)
  {
   printf("    장      르 : SF");
  }
  if(video[i]->ivkind == 2)
  {
   printf("    장      르 : 액션");
  }
  if(video[i]->ivkind == 3)
  {
   printf("    장      르 : 멜로");
  }
  if(video[i]->ivkind == 4)
  {
   printf("    장      르 : 만화");
  }
  if(video[i]->ivkind == 5)
  {
   printf("    장      르 : 에로");
  }
  printf("    대 여 횟 수 : %d",video[i]->ivRentCount);
  if(video[i]->ivRent==1)
  {
   printf("    현 재 재 고 : 있  음 ");
  }
  else
  {
   printf("    현 재 재 고 : 대여중 ");
  }
  printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
  Count++;
  if(Count%5 == 0)
   {
    printf("                                                             Press Any Key");
    getch();
    system("cls");
    printf("   ──비 디 오  정 보── ");
   }
 }
 if(Count%5!=0)
 {
 printf("                                                             Press Any Key");
 }
}

void VNodePrintIII(VI * video[],int ivCount)
{
 int i;
 system("cls");
 printf(" --대여중인 비디오 리스트-- ");
 printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
 for(i=0;i {
  if(video[i]->ivRent==0)
  {
   printf("  비디오 이름 : %s   비디오 코드 : %d ",video[i]->pvTitle,video[i]->ivCode);
  }
 }
 printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
 printf("                                                             Press Any Key");
}

void VFileSave(VI * video[],int ivCount)
{
 FILE *fp;
 int i;

 fp=fopen("Video.txt","w");
 for(i=0;i {
  if(video[i] != NULL)
  {
   fprintf(fp,"%s ",video[i]->pvTitle);
   fprintf(fp,"%d ",video[i]->ivCode);
   fprintf(fp,"%d ",video[i]->ivkind);
   fprintf(fp,"%d %d ",video[i]->ivRent,video[i]->ivRentCount);
  }
 }
 fclose(fp);
}

int VFileLoad(VI * video[],int ivCount)
{
 FILE * fp;
 char temp[256];
 
 fp = fopen("Video.txt","r");
 if (fp == NULL)
 {
  printf(" 파일이 없습니다.");
  return ivCount;
 }
 
 while(1)
 {
  fgets(temp,256,fp);
  if (feof(fp))
  {
   break;
  }
  
  video[ivCount] = (VI *)malloc(sizeof(VI));
  
  video[ivCount]->pvTitle = (char *)malloc(strlen(temp));
  strncpy(video[ivCount]->pvTitle,temp,strlen(temp)-1);
  video[ivCount]->pvTitle[strlen(temp)-1] = '';
  
  fscanf(fp,"%d",&video[ivCount]->ivCode);
  
  fscanf(fp,"%d",&video[ivCount]->ivkind);

  fscanf(fp,"%d %d",&video[ivCount]->ivRent,&video[ivCount]->ivRentCount);
  fgets(temp,256,fp);
  ivCount++;
 }
 return ivCount;
}

//####################################대여관리 함수 시작###########################################33

int Rrent(RE * rent[],CL * client[],VI * video[],int irCount,int icCount,int ivCount)
{
 int cTelSearch;
 int i,j; //for문 변수
 int k; //비디오 코드 변수

 if(irCount>=RENTMAX)
 {
  printf("더이상 대여정보를 입력할 수 있는 공간이없습니다. ");
  return irCount;
 }
 
 cTelSearch = RTelSearch(client,icCount);
 if(cTelSearch==-1)
 {
  printf(" 등록되지 않은 번호입니다. 고객 등록을 해주세요!! ");
  return irCount;
 }
 for(i=0;i {
  if(strcmp(client[cTelSearch]->pcTel,rent[i]->prTel)==0 && rent[i]->irReturn==0)
  {
   for(j=0;j   {
    if(rent[i]->irCode==video[j]->ivCode)
    {
     printf("◈ 미반납비디오 ▷제 목 : %s ▷대여일 : %d ",video[j]->pvTitle,rent[i]->irDay);
    }
   }
  }
 }
 printf(" 대여할 비디오 코드 : ");
 scanf("%d",&k);
 fflush(stdin);
 for(i=0;i {
  if(video[i]->ivCode==k)
  { 
   if(video[i]->ivRent==0)
   {
    printf(" ♣ 지금 비디오가 대여 중입니다.────────── ");
    getch();
    return irCount;

   }
   else
   {
    rent[irCount] = (RE *)malloc(sizeof(RE));
    rent[irCount]->irCode=k;
    video[i]->ivRent=0;
    video[i]->ivRentCount+=1;

    rent[irCount]->prTel = (char *)malloc(strlen(client[cTelSearch]->pcTel)); //전화번호 입력
    strcpy(rent[irCount]->prTel,client[cTelSearch]->pcTel);

    printf("비디오 대여일 EX)20020715 : ");
    scanf("%d",&rent[irCount]->irDay);
    fflush(stdin);
    rent[irCount]->irReturn=0;
    return ++irCount;
   }
  }
 }
 printf(" ♣ 존재하지 않는 비디오 코드입니다.──────────");
 getch();
 return irCount;
}

int RTelSearch(CL * client[],int icCount)
{
 char cTelSearch[256];
 int i;
 printf(" 고객의 전화 번호를 입력하세요 : ");
 gets(cTelSearch);
 for(i=0;i {
  if(strcmp(cTelSearch,client[i]->pcTel)==0)
  {
   return i;
  }
 }
 return -1;
}

void RrentPrint(RE * rent[],CL * client[],VI * video[],int irCount,int icCount,int ivCount)
{
 int i,k;
 int cTelSearch;
 cTelSearch = RTelSearch(client,icCount);
 if(cTelSearch==-1)
 {
  printf(" 등록되지 않은 번호입니다. 고객 등록을 해주세요!! ");
  return;
 }
 system("cls");
 printf("   ──개 인 대 여  정 보── ");
 printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
 printf(" 이       름 : %s     전 화 번 호 : %s ",client[cTelSearch]->pcName,client[cTelSearch]->pcTel);
 for(i=0;i {
  if(strcmp(client[cTelSearch]->pcTel,rent[i]->prTel)==0)
  {
   for(k=0;k   {
    if(rent[i]->irCode == video[k]->ivCode)
    {
     if(video[k]->ivRent==0)
     {
      printf(" 비디오 제목 : %s  비디오 코드 : %d  대   여   일 : %d   반 납 상 황 : 미반납 ",video[k]->pvTitle,rent[i]->irCode,rent[i]->irDay);
     }
     else
     {
      printf(" 비디오 제목 : %s  비디오 코드 : %d  대   여   일 : %d   반 납 상 황 : %d ",video[k]->pvTitle,rent[i]->irCode,rent[i]->irDay,rent[i]->irReturn);
     }
    }
   }
  }
 }
 printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ");
}

void RFileSave(RE * rent[],int irCount)
{
 FILE *fp;
 int i;

 fp=fopen("Rent.txt","w");
 for(i=0;i {
  fprintf(fp,"%s ",rent[i]->prTel);
  fprintf(fp,"%d ",rent[i]->irCode);
  fprintf(fp,"%d ",rent[i]->irDay);
  fprintf(fp,"%d ",rent[i]->irReturn);
 }
 fclose(fp);
}

int RFileLoad(RE* rent[],int irCount)
{
 FILE * fp;
 char temp[256];
 
 fp = fopen("Rent.txt","r");
 if (fp == NULL)
 {
  printf(" 파일이 없습니다.");
  return irCount;
 }
 
 while(1)
 {
  fgets(temp,256,fp);
  if (feof(fp))
  {
   break;
  }
  
  rent[irCount] = (RE *)malloc(sizeof(RE));
  
  rent[irCount]->prTel = (char *)malloc(strlen(temp));
  strncpy(rent[irCount]->prTel,temp,strlen(temp)-1);
  rent[irCount]->prTel[strlen(temp)-1] = '';
  
  fscanf(fp,"%d",&rent[irCount]->irCode);
  fscanf(fp,"%d",&rent[irCount]->irDay);
  fscanf(fp,"%d",&rent[irCount]->irReturn);
  fgets(temp,256,fp);
  irCount++;
 }
 return irCount;
}

void RReturn(RE * rent[],CL * client[],VI * video[],int irCount,int icCount,int ivCount)
{
 int cTelSearch;
 int i,j; //for문 변수
 int k;
 int day;
 char temp[256];

 cTelSearch = RTelSearch(client,icCount);
 if(cTelSearch==-1)
 {
  printf(" 등록되지 않은 번호입니다. 고객 등록을 해주세요!! ");
  return;
 }

 strcpy(temp,client[cTelSearch]->pcTel);

 printf("비디오 코드 : ");
 scanf("%d",&k);
 fflush(stdin);
 for(i=0;i {
  if(strcmp(client[cTelSearch]->pcTel,rent[i]->prTel)==0)
  {
   day = rent[i]->irDay;
   for(j=0;j   {
    if(rent[i]->irCode == k)
    {
     if(video[j]->ivRent==0)
     {
      RNodeFree(rent,i);
      rent[cTelSearch] = (RE *)malloc(sizeof(RE));
      rent[cTelSearch]->prTel = (char *)malloc(strlen(client[cTelSearch]->pcTel)); //전화번호 입력
      strcpy(rent[cTelSearch]->prTel,client[cTelSearch]->pcTel);
      rent[cTelSearch]->irCode=k;
      video[j]->ivRent=1;
      rent[cTelSearch]->irDay=day;
      printf("비디오 반납일 EX)20020715 : ");
      scanf("%d",&rent[cTelSearch]->irReturn);
      fflush(stdin);
      return;
     }
    }
   }
  }
 }
 printf(" ♣ 잘못된 비디오 코드입니다.──────────");
 getch();
}

void RNodeFree(RE * rent[],int irSearch)
{
 free(rent[irSearch]->prTel);

 SAFE_FREE(rent[irSearch]);
}

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,142 명
  • 현재 강좌수 :  36,216 개
  • 현재 접속자 :  297 명