Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Word Best
Language: C/C++
Code:


/*
작품명   WordBest ver.171204
제작자
      정보통신융합공학부_응용컴퓨터프로그래밍_11분반_3조
      1360015 나주현 + 1360037 이승희 + 1460060 이알렉스

   사용하기 전에 프로젝트 디렉토리, ID 디렉토리 바꾼 뒤 사용
*/

#define _CRT_SECURE_NO_WARNINGS   // scanf() 경고 막음
#define _CRT_NONSTDC_NO_WARNINGS  // _getch() 경고 막음

#define totalQNum 10   // 총 문제수 10

#include <stdio.h>
#include <stdlib.h>   // rand() 함수 포함하는 헤더파일
#include <time.h>   // time() 함수 포함하는 헤더파일
#include <conio.h>   // _getch() 함수 포함하는 헤더파일
#include <windows.h>
//Sleep(), strcat(), system() 함수 포함하는 헤더파일



//char id_direc[100] = "C:/Users/나주현/source/repos/2017cProject/2017cProject/ID/";
char id_direc[100] = "C:/Users/이승희/source/repos/2017cProject1/2017cProject1/ID/";

//아이디 디렉토리

//char project_direc[100] = "C:/Users/나주현/source/repos/2017cProject/2017cProject/";
char project_direc[100] = "C:/Users/이승희/source/repos/2017cProject1/2017cProject1/";

//프로젝트 디렉토리


void MainMenu(); // 메인 선택지 출력

void funDivide(void (*fp)()); // 메인 기능 선택하기 위한 함수포인터

void WordTest(); //[1] 단어시험 기능

void TestEnd(); // 단어시험 종료

void TestRecording(); // 단어시험 결과값 저장

void WordReview(); // 복습하기 기능

int Select();
/*
엔터를 입력하지 않고 선택할 수 있도록 _getch() 함수 사용
입력 받은 문자(1~4)를 아스키 코드를 통해 정수(1~4)로 변환
*/

int Shuffle(int); // 0 ~ (int-1) 중 랜덤 정수 1개 출력

int Arysize(char(*strary)[30], char str[]);
/*
배열크기 반환하는 함수
고른 단어장 마다 배열의 크기(단어의 개수)가 다르기 때문에 사용
*/

void WordSetting(); // [2] 단어장 설정 기능

void Login(); // [3] 로그인 기능

void NewId();   // 아이디 생성 기능

void Logout(); //  [3] 로그아웃 기능

void Record();   // [4] 기록확인 기능

char engWords[500][30] = { '\0' }; //영어 단어배열

char korWords[500][30] = { '\0' }; //한글 뜻 단어배열


FILE *fpEngWord;   // 영어 단어배열 불러올 파일의 포인터

FILE *fpKorWord;   // 한글 뜻 단어배열 불러올 파일의 포인터

FILE *fpID;   // 아이디 저장된 파일의 포인터


int rightNum, wrongNum;   // 맞은 개수, 틀린 개수

char user_id[30] = { '\0' };   // 사용자 아이디

char id_login[100] = { '\0' };   //로그인 하기 위한 문자열

int wrong[totalQNum] = { 0 };

struct now_times
{
   int year;
   int month;
   int day;
};
typedef struct now_times now_times;



int main(void) {


   printf("\n\n");
   printf("\t┏━━━━━━━━━━━━━━━┓\n");
   printf("\t┃                              ┃\n");
   printf("\t┃     W O R D   B E S T        ┃\n");
   printf("\t┃                              ┃\n");
   printf("\t┗━━━━━━━━━━━━━━━┛\n");
   printf("\n");
   printf("\n");

   MainMenu(); // 메인기능 선택지

   return 0;
}

void MainMenu() {

   
   printf("\t  [1] 테스트 시작\n\n");

   printf("\t  [2] 단어장 설정\n\n");

   if (*user_id == '\0') // 로그인 했는지 확인해서 [3]번 선택지 변경
   {
      printf("\t  [3] 로그인\n\n");
   }
   else
   {
      printf("\t  [3] 로그아웃\n\n");
   }

   printf("\t  [4] 기록확인\n\n");
   
   int choice = 0;

   choice = Select();

   switch (choice) {

   case 1:
      system("cls"); //화면 지워줌

      funDivide(WordTest); // 메인기능 실행

      break;

   case 2:
      system("cls");

      funDivide(WordSetting);

      break;

   case 3:
      if (*user_id == '\0')
      {
         system("cls");

         funDivide(Login);
      }
      else
      {
         system("cls");

         funDivide(Logout);
      }
      break;

   case 4:
      system("cls");

      funDivide(Record);

      break;

   default:
      printf("\t *잘못된 번호를 입력하셨습니다.\n");

      Sleep(500);

      system("cls");

      main();

      break;
   }
   

}
void funDivide(void (*fp)())
{

   fp();

}
int Select()
{
   int num = 0;
   char ch = '\0';

   ch = _getch();   // 엔터키 없이 입력

   if ((int)ch == 49) {   // 아스키 코드를 이용해 1~4 분류
      num = 1;
   }
   else if ((int)ch == 50)
   {
      num = 2;
   }
   else if ((int)ch == 51)
   {
      num = 3;
   }
   else if ((int)ch == 52)
   {
      num = 4;
   }
   else if ((int)ch == 57)
   {
      system("cls");
      main();
   }

   return num;
}

void WordTest()
{

   if (*korWords[0] == NULL) {   // 따로 단어장 설정을 하지 않았을 경우 기본단어

      char *korWord1[30] = { "사과","수박","딸기","오렌지","멜론","배","복숭아" };
      char *engWord1[30] = { "apple","watermelon","strawberry","orange","melon","pear","peach" };

      for (int i = 0; i < 7; i++) {

         strcpy(korWords[i], korWord1[i]);

         strcpy(engWords[i], engWord1[i]);

      }
   }

   int arysize = Arysize(korWords, korWords[0]);   // 배열 크기확인
                                       //printf("%d\n", arysize);

   int q = 0;   // 문제 반복시킬 인수
   rightNum = 0, wrongNum = 0;   // 맞은 문제, 틀린 문제 값 초기화


   while (q<totalQNum)   // totalQNum번 까지 문제 생성하기 위한 반복문
   {

      int word_shf[4] = { '\0' }; // 단어 배열 중 선택지를 뽑기 위한 배열

      int select_shf[4] = { '\0' }; // 선택지를 섞기위한 배열



      srand((long)time(NULL));   //   난수의 발생 규칙 바꿈



      for (int j = 0; j < 4; j++) {   // 선택지 4개를 고르기 위한 반복문



         *(word_shf + j) = Shuffle(arysize);   // 단어 배열 전체중 하나씩을 뽑아 배열에 저장한다



         for (int k = 0; k < j; k++) {   // 중복되었는지 확인하려는 반복문

            if (*(word_shf + j) == *(word_shf + k)) {

               j--;

            }

         }


      }

      srand((long)time(NULL));   //   난수의 발생 규칙 바꿈

      for (int t = 0; t < 4; t++)   // 선택지 4개를 섞기 위한 반복문
      {

         *(select_shf + t) = Shuffle(4);

         int y = 0;

         while (y<t)   // 선택지 4개중 중되는 부분을 제거하기 위한 반복문
         {

            if (*(select_shf + t) == *(select_shf + y))
            {

               t--;

               break;

            }

            y++;
         }

      }
      

      int ansNum = 0;      // 선택지를 고르기 위한 변수

      int testTime = 5;   // 문제를 푸는데 주어진 시간 (초)

      for (;;) {   // 문제 생성

         printf("\n");
         printf("\n");
         printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
         printf("\t┃홈으로(9)                                     ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃          %12s                        ┃\n", engWords[*word_shf]);
         printf("\t┃                                              ┃\n");
         for (int l = 0; l < 4; l++)
         {
            printf("\t┃             (%d) %-20s         ┃\n", l + 1, korWords[*(word_shf + (*(select_shf + l)))]);
         }

         /*   키입력이 있는지 검사하는 조건문
            kbhit() 함수는 키입력이 없을때 0, 있을 때 1을 반환함
            이 조건문이 없을 시 문제를 출력하던 도중 입력 받기 위해 대기하게됨
         */
         if (kbhit() == 1)
         {
            ansNum = Select();
            if (*(select_shf + (ansNum - 1)) == 0) // 정답체크
            {
               printf("\t┃                                              ┃\n");
               printf("\t┃                                              ┃\n");
               printf("\t┃             *정답입니다                      ┃\n");
               rightNum++;
            }
            else
            {
               printf("\t┃                                              ┃\n");
               printf("\t┃    *오답입니다                               ┃\n");
               printf("\t┃    *%-12s %-20s        ┃\n", engWords[*word_shf], korWords[*word_shf]);
               wrong[wrongNum] = *word_shf;
               wrongNum++;
            }
            printf("\t┃                                              ┃\n");
            printf("\t┃      ○ : %2d   X : %2d      문제 : %2d /%2d    ┃\n", rightNum, wrongNum, q + 1, totalQNum);
            printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

            Sleep(1000);   
            system("cls");
            break;
         }
         else if (testTime <= 0) {   // 입력이 없을 경우 시간이 다되면
            wrongNum++;
            printf("\t┃                                              ┃\n");
            printf("\t┃    *오답입니다                               ┃\n");
            printf("\t┃    *%-12s %-20s        ┃\n", engWords[*word_shf], korWords[*word_shf]);
            printf("\t┃                                              ┃\n");
            printf("\t┃                                              ┃\n");
            printf("\t┃      ○ : %2d   X : %2d      문제 : %2d /%2d    ┃\n", rightNum, wrongNum, q + 1, totalQNum);
            printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
       
            Sleep(1000);
            system("cls");
            break;
         }
         else
         {
            printf("\t┃                                              ┃\n");
            printf("\t┃                                              ┃\n");
            printf("\t┃                             남은시간 %-2d초    ┃\n", testTime);
            printf("\t┃                                              ┃\n");
            printf("\t┃      ○ : %2d   X : %2d      문제 : %2d /%2d    ┃\n", rightNum, wrongNum, q + 1, totalQNum);
            printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
            Sleep(1000);
            testTime--;

            system("cls");
         }
      }
      q++;
   }

   TestEnd();

}

int Shuffle(int MaxNum)
{
   int num = rand() % MaxNum;

   return num;
}

int Arysize(char(*strary)[30], char str[])   // 배열 단어 수 검사
{
   int num = 0;
   int i = 0;
   while (i<500)
   {
      if (**(strary + i) == '\0')   //파일의 끝에서 종료
      {
         break;
      }
      num++;
      i++;
   }
   return num;

}
void TestEnd()
{

   printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
   printf("\t┃홈으로(9)                                     ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");

   if (*user_id == '\0')
   {

      printf("\t┃    # 단어 테스트 결과                        ┃\n");

   }
   else
   {

      printf("\t┃    # %-10s님 환영합니다                 ┃\n", user_id);

   }
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃            *맞은 개수 : %2d문제 중 %2d개       ┃\n", totalQNum, rightNum);
   printf("\t┃                                              ┃\n");
   printf("\t┃            *틀린 개수 : %2d개                 ┃\n", wrongNum);
   printf("\t┃                                              ┃\n");

   printf("\t┃            @ 점수 : %3.0lf점                    ┃\n", (double)rightNum / totalQNum * 100);

   printf("\t┃                                              ┃\n");
   if (*user_id == NULL)
   {
      printf("\t┃                       .                      ┃\n");
      printf("\t┃  *로그인을 하지않아  결과가 저장되지 않습니다┃\n");


   }
   else
   {
      TestRecording();
      printf("\t┃                                              ┃\n");
      printf("\t┃                                              ┃\n");

   }
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃  다시하기(1)                틀린 단어보기(2) ┃\n");
   printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

   int answer = 0;

   answer = Select();

   system("cls");

   if (answer == 1) {   // 다시하기 선택

      WordTest();   // [1] 단어 시험 시작

   }
   else if (answer == 2) {   // 틀린단어보기 선택

      WordReview();

   }
   else {
      main();
   }
}
void TestRecording()
{


   time_t times;   // 현재 시스템 시간을 불러옴

   struct tm *tp;

   time(&times);

   tp = localtime(&times);

   now_times now;   // 현재 시간을 저장하기 위한 구조체 사용

   now.year = tp->tm_year + 1900;

   now.month = tp->tm_mon + 1;

   now.day = tp->tm_mday;


   fpID = fopen(id_login, "a");   // 텍스트를 끝에 추가하기 위해 파일모드 a

   if (fpID == NULL)
   {
      system("cls");
      printf("파일이 열리지않아 결과 저장이 어렵습니다.");
      Sleep(500);
      main();
   }

   fprintf(fpID, "%4d-%2d-%-2d   %-3.0lf   %2d\n", now.year, now.month, now.day, (double)rightNum / totalQNum * 100, wrongNum);
   fclose(fpID);

}

void WordReview()
{
   printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
   printf("\t┃홈으로(9)                                     ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃      # 틀린 단어입니다                       ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃      # 총 %2d문제 틀리셨습니다                ┃\n", wrongNum);
   printf("\t┃                                              ┃\n");

   for (int i = 0; i < wrongNum; i++)
   {
      printf("\t┃    *%-12s %-28s┃\n", engWords[*(wrong + i)], korWords[*(wrong + i)]);
      *(wrong + i) = 0;
   }
   printf("\t┃                                              ┃\n");
   printf("\t┃                                  다시하기(1) ┃\n");
   printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

   int answer = 0;
   answer = Select();
   system("cls");

   if (answer == 1)   // 다시하기 선택
   {
      WordTest();   // [1] 단어 시험 시작
   }
   else
   {

      main();
   }
}

void WordSetting()
{
   while (1) {

      char answer = '\0';
      int ansNum = 0;

      printf("\n\n");
      printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
      printf("\t┃홈으로(9)                                     ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃      # 단어장 선택                           ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃      # 원하는 난이도의 단어장을 선택해주세요 ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃                                              ┃\n");

      if (kbhit() == 1)
      {

         ansNum = Select();

         char Kor_direc[100] = { '\0' };
         char Eng_direc[100] = { '\0' };

         if (ansNum == 1) {

            strcat(Kor_direc, project_direc);
            strcat(Kor_direc, "basicKor.txt");

            strcat(Eng_direc, project_direc);
            strcat(Eng_direc, "basicEng.txt");

            fpKorWord = fopen(Kor_direc, "r");
            fpEngWord = fopen(Eng_direc, "r");


         }
         else if (ansNum == 2) {

            strcat(Kor_direc, project_direc);
            strcat(Kor_direc, "EasyKor.txt");

            strcat(Eng_direc, project_direc);
            strcat(Eng_direc, "EasyEng.txt");

            fpKorWord = fopen(Kor_direc, "r");
            fpEngWord = fopen(Eng_direc, "r");


         }
         else if (ansNum == 3) {

            strcat(Kor_direc, project_direc);
            strcat(Kor_direc, "MidKor.txt");

            strcat(Eng_direc, project_direc);
            strcat(Eng_direc, "MidEng.txt");

            fpKorWord = fopen(Kor_direc, "r");
            fpEngWord = fopen(Eng_direc, "r");

         }
         else if (ansNum == 4) {

            strcat(Kor_direc, project_direc);
            strcat(Kor_direc, "HardKor.txt");

            strcat(Eng_direc, project_direc);
            strcat(Eng_direc, "HardEng.txt");

            fpKorWord = fopen(Kor_direc, "r");
            fpEngWord = fopen(Eng_direc, "r");


         }
         else {   // 선택지에 없는 번호가 입력되면
            WordSetting();
         }

         if (fpKorWord == NULL || fpEngWord == NULL) {
            system("cls");
            printf("파일이 열리지 않습니다.");
            system("cls");
            main();
         }

         printf("\t┃                                              ┃\n");
         printf("\t┃      # 파일 확인되었습니다                   ┃\n");
         printf("\t┃                                              ┃\n");

         int ch = 0;   // fgetc() 반환값 저장
         int wordCount = 0;
         int wordNum = 0;

         for (;;) {   //한글단어 배열 읽어오기

            ch = fgetc(fpKorWord);

            if (ch == EOF) {
               break;
            }

            if (ch == '\n')
            {
               wordNum++;
               wordCount = 0;
            }
            else
            {
               *(*(korWords + wordNum) + wordCount) = ch;

               wordCount++;
            }
         }

         wordNum = 0;
         wordCount = 0;
         printf("\t┃                *한글 단어 배열 불러왔습니다  ┃\n");
         printf("\t┃                                              ┃\n");


         for (;;) {   //영어단어 배열 읽어오기

            ch = fgetc(fpEngWord);

            if (ch == EOF) {
               break;
            }
            if (ch == '\n')
            {
               wordNum++;
               wordCount = 0;
            }
            else
            {
               *(*(engWords + wordNum) + wordCount) = ch;

               wordCount++;
            }
         }
         printf("\t┃                *영어 단어 배열 불러왔습니다  ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃      # 파일을 모두 읽었습니다                ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃      # 단어개수는 총 %2d개입니다             ┃\n", wordNum + 1);
         printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

         fclose(fpKorWord);

         fclose(fpEngWord);

         Sleep(1000);
         system("cls");
         main();
         break;

      }
      else
      {
         printf("\t┃                                              ┃\n");
         printf("\t┃        [1] S a m p l e                       ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃        [2] E a s y                           ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃        [3] M e d i u m                       ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃        [4] H a r d                           ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
         Sleep(1000);
         system("cls");
      }

   }
}
void Login()
{


   printf("\n\n");
   printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃      # 로그인                                ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃      # 사용자 이름  :                        ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

   COORD Pos = { 33, 9 };
   SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
   scanf(" %s", user_id);



   strcat(id_login, id_direc);   //디텍토리 문장열 붙임
   strcat(id_login, user_id);
   strcat(id_login, ".txt");   // 디텍토리에 user_id.txt 붙임




   fpID = fopen(id_login, "r");   // 파일이 있는지 검사

   system("cls");

   if (fpID == NULL) {

      system("cls");

      NewId();

   }
   else {

      printf("\n\n");
      printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
      printf("\t┃홈으로(9)                                     ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃      # 로그인 완료                           ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃      # %-10s님 환영합니다               ┃\n", user_id);
      printf("\t┃                                              ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┃                                              ┃\n");
      printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

      Sleep(1000);
      fclose(fpID);
      system("cls");
      main();
   }
}
void NewId()
{


   printf("\n\n");
   printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
   printf("\t┃홈으로(9)                                     ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃      # 존재하지 않는 아이디입니다            ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃      # 아이디를 생성하시겠습니까?            ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃           예(1)         아니오(2)            ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

   int answer = 0;

   answer = Select();

   if (answer == 1)
   {
      fpID = fopen(id_login, "wt");   // 파일이 있는지 검사
      fprintf(fpID, "\n");
      system("cls");

      if (fpID == NULL) {

         printf("*회원가입이 불가능합니다\n\n");
         printf("*관리자에게 문의하세요\n");
         Sleep(500);
         main();

      }
      else {

         printf("\n\n");
         printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
         printf("\t┃홈으로(9)                                     ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃      # 로그인 완료                           ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃      # %-10s님 환영합니다               ┃\n", user_id);
         printf("\t┃                                              ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┃                                              ┃\n");
         printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

         Sleep(1000);
         fclose(fpID);
         system("cls");
         main();
      }

   }
   else
   {
      system("cls");

      *user_id = '\0';
      *id_login = '\0';

      main();
   }
}
void Logout()
{
   *user_id = '\0';
   *id_login = '\0';

   printf("\n\n");
   printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
   printf("\t┃홈으로(9)                                     ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃      # 로그아웃 완료                         ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃      # 다른 아이디로 로그인 하시겠습니까?    ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃           예(1)         아니오(2)            ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

   int answer = 0;

   answer = Select();
   system("cls");

   if (answer == 1) {

      Login();

   }
   else {

      main();

   }

}
void Record()
{
   int res;   // fscanf 함수의 반환값 저장

   if (*id_login == '\0') {
      Login();
   }

   fpID = fopen(id_login, "r");

   if (fpID == NULL)
   {
      printf("파일을 찾을 수 없습니다\n");
      Sleep(1000);
      system("cls");
      main();
   }

   char str[33] = { '\0' };


   printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━┓\n");
   printf("\t┃홈으로(9)                                     ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃    # %-10s님의 테스트 결과 내역입니다   ┃\n", user_id);
   printf("\t┃                                              ┃\n");
   printf("\t┃    # 시간 순으로 정렬된 내역입니다           ┃\n");
   printf("\t┃                                              ┃\n");
   printf("\t┃          날짜     점수  틀린개수             ┃\n");
   printf("\t┃  ------------------------------------------  ┃\n");

   for (;;)
   {
      res = (int)fgets(str, sizeof(str), fpID);

      if (res == NULL)
      {
         break;
      }
      printf("                 %s", str);
   }

   printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

   fclose(fpID);
   getch();
   system("cls");
   main();

}
Comments: