Guest User

Untitled

a guest
Dec 9th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <windows.h>
  5. #include <time.h>
  6.  
  7.  
  8. typedef struct client{
  9. int ID;
  10. char PW[100],NAME[100],ADDRESS[100],PNUM[100];
  11. struct client* next;
  12. }client;
  13.  
  14. typedef struct book
  15. {
  16. int book_num;
  17. char book_name[50];
  18. char publisher[50];
  19. char author[20];
  20. long long ISBN;
  21. char book_address[50];
  22. char Y_N[2];
  23. struct book *next;
  24. }book;
  25.  
  26. typedef struct borrow
  27. {
  28. int stu_num;
  29. int book_num;
  30. time_t b_date;
  31. time_t r_date;
  32. struct borrow *next;
  33. }borrow;
  34.  
  35. int temp1;
  36. int IDD;
  37. /////////register/////////
  38. client* create_linkedlist_client(int n);
  39. int line_of_file(char* name);
  40.  
  41. void download_linkedlist_client(client* head);
  42. void duplicate_inspection_client(client* head);
  43. void sort_linkedlist_client(client* head);
  44. void upload_linkedlist_client(client* head);
  45. void change_my_info(client* head,int n);
  46. void withdrawal(client* head,int n);
  47.  
  48. //////////login///////////
  49. int login(client* head,int id,char* pw);
  50. client* create_linkedlist_client_login(int n);
  51.  
  52. ////////book///////////
  53. book* create_linkedlist_book(int n);
  54. void download_linkedlist_book(book* head);
  55. void duplicate_inspection_book(book* head);
  56. void sort_linkedlist_book(book* head);
  57. void upload_linkedlist_book(book* head);
  58.  
  59. void search_linkedlist_book_ISBN(book* head);
  60. void search_linkedlist_book_bookname(book* head);
  61. void search_linkedlist_book_publisher(book* head);
  62. void search_linkedlist_book_author(book* head);
  63. void search_linkedlist_book_all(book* head);
  64.  
  65. ////////////////////////////////////////
  66.  
  67. void Register_linkedlist_book(int booknum,book* head);
  68. int Readbookname_linkedlist_book(book* head,int length);
  69. void delete_linkedlist_book(book* head);
  70. client* create_NOINPUT_linkedlist_client(int n);
  71. client* search_by_clientname(client* head);
  72. client* search_by_ID(client* head);
  73. client* Print_all_client(client* head);
  74. /////////////////////////////////////////////////
  75.  
  76. borrow* borrow_create_linkedlist(int n);
  77. int borrow_search_linkedlist_book_bookname(book* head);
  78. int borrow_search_linkedlist_book_ISBN(book* head);
  79. borrow* borrow_input_linkedlist(book* head);
  80.  
  81. ///////////////////////////////////////
  82.  
  83.  
  84. void return_download(borrow* head);
  85. void print_all_book(int ID,book* head,borrow* headhead);
  86. void Print_all_book(int ID,book* head,borrow* headhead);
  87.  
  88.  
  89.  
  90. int identifier=0;
  91.  
  92. // main start
  93. int main()
  94. {
  95. client* HEAD=NULL;
  96. client* CLIENT=NULL;
  97. book* head=NULL;
  98. borrow* BORROW=NULL;
  99.  
  100. int servicestart;
  101.  
  102. while(1)
  103. {
  104. system("clear");
  105. puts(">>Library Service<<\n1.Register 2.Login 3.Exit Program");
  106. scanf("%d",&servicestart);
  107.  
  108.  
  109.  
  110. switch(servicestart)
  111. {
  112.  
  113.  
  114. case 1:
  115. {
  116.  
  117. identifier=0;
  118. system("clear");
  119.  
  120. puts("You selected Register");
  121. puts("Enter Student ID | Password | Name | Address | Phonenumber");
  122. puts("ex)20180345|ssu2018|DanielHong|KEPCO,Gaepo-dong,Gangnam-gu,seoul|01031414473");
  123. printf("\n\n");
  124.  
  125.  
  126. HEAD=create_linkedlist_client(line_of_file("client.txt")+1); //Create , INPUT VALUES.
  127. download_linkedlist_client(HEAD);
  128. duplicate_inspection_client(HEAD);
  129. if(identifier==0)
  130. {
  131. sort_linkedlist_client(HEAD);
  132. upload_linkedlist_client(HEAD);
  133. }
  134.  
  135. break;
  136. }
  137.  
  138.  
  139.  
  140.  
  141.  
  142. case 2:
  143. {
  144.  
  145. int login_identifier;
  146. char PW[100];
  147. int admin_identifier_int;
  148. char admin_identifier_string[10];
  149. int break_or_admin=0;
  150.  
  151. while(1)
  152. {
  153. system("clear");
  154. puts(">>Login<<");
  155.  
  156. fputs("ID:",stdout);
  157. admin_identifier_int=scanf("%d",&IDD);
  158.  
  159.  
  160. if (admin_identifier_int != 1) //string
  161. {
  162. system("clear");
  163. puts("Did you entered string?");
  164. puts("If you enter admin , connected with administrator authority");
  165. puts("If you enter other string , goes back to main menu");
  166. while(getchar() !='\n'); //clean input buffer,beacuse of scanf error.
  167. scanf("%s",admin_identifier_string);
  168. if(strcmp(admin_identifier_string,"admin")==0)
  169. {
  170. break_or_admin=1;
  171. break;
  172. }
  173.  
  174. else
  175. {
  176. break_or_admin=0;
  177. break;
  178. }
  179.  
  180. }
  181.  
  182.  
  183.  
  184. fputs("PW:",stdout);
  185. scanf("%s",PW);
  186.  
  187. HEAD=create_linkedlist_client_login(line_of_file("client.txt"));
  188. download_linkedlist_client(HEAD);
  189. login_identifier=login(HEAD,IDD,PW);
  190.  
  191. if(login_identifier==0) //Wrong
  192. {
  193. system("clear");
  194. puts("Wrong ID or PW");
  195. puts("Try again in 3sec");
  196. Sleep(3000);
  197. }
  198.  
  199.  
  200. if(login_identifier==1) //Pass
  201. break;
  202.  
  203.  
  204.  
  205. }
  206.  
  207.  
  208. if(login_identifier==1 && break_or_admin!=1)
  209. {
  210. while(1)
  211. {
  212.  
  213. head=create_linkedlist_book(line_of_file("book.txt"));
  214. download_linkedlist_book(head);
  215.  
  216.  
  217. system("clear");
  218. int input=0;
  219. puts(">>>MENU<<<");
  220.  
  221. puts("1.Search book 2.My borrow list 3.Edit personal information");
  222. puts("4.Membership withdrawal 5.Logout 6.Exit program");
  223. scanf("%d",&input);
  224.  
  225. switch(input)
  226. {
  227. case 1:
  228. {
  229.  
  230. int menuselect=0;
  231. system("clear");
  232. puts("1.Search with book name 2.Search with publisher 3.Search with ISBN");
  233. puts("4.Search with author 5.search all 6.previous menu");
  234. scanf("%d",&menuselect);
  235.  
  236. switch(menuselect)
  237. {
  238. case 1:
  239. {
  240. search_linkedlist_book_bookname(head);
  241. break;
  242. }
  243. case 2:
  244. {
  245. search_linkedlist_book_publisher(head);
  246. break;
  247. }
  248. case 3:
  249. {
  250. search_linkedlist_book_ISBN(head);
  251. break;
  252. }
  253. case 4:
  254. {
  255. search_linkedlist_book_author(head);
  256. break;
  257. }
  258. case 5:
  259. {
  260. search_linkedlist_book_all(head);
  261. break;
  262. }
  263. case 6:
  264. {
  265. break;
  266. }
  267. }
  268.  
  269. break;
  270. }
  271.  
  272.  
  273. case 2:
  274. {
  275. system("clear");
  276.  
  277. BORROW=borrow_create_linkedlist(line_of_file("borrow.txt"));
  278. return_download(BORROW);
  279.  
  280.  
  281. head=create_linkedlist_book(line_of_file("book.txt"));
  282. download_linkedlist_book(head);
  283.  
  284.  
  285. Print_all_book(IDD,head,BORROW);
  286. break;
  287. }
  288.  
  289. case 3:
  290. {
  291. HEAD=create_linkedlist_client_login(line_of_file("client.txt"));
  292. download_linkedlist_client(HEAD);
  293. sort_linkedlist_client(HEAD);
  294. change_my_info(HEAD,IDD);
  295. }
  296.  
  297. case 4:
  298. {
  299. HEAD=create_linkedlist_client_login(line_of_file("client.txt"));
  300. download_linkedlist_client(HEAD);
  301. sort_linkedlist_client(HEAD);
  302. withdrawal(HEAD,IDD);
  303. }
  304. case 5:
  305. {
  306. break;
  307. }
  308. case 6:
  309. {
  310. return 0;
  311. }
  312.  
  313.  
  314.  
  315.  
  316. }
  317. if(input==5)
  318. break;
  319.  
  320. } //while
  321.  
  322. } //if
  323.  
  324.  
  325.  
  326. if(break_or_admin==1)
  327. {
  328.  
  329. while(1)
  330. {
  331. int foradmin=0;
  332.  
  333. system("clear");
  334. puts("1.Register book 2.Delete book 3.Borrow book");
  335. puts("4.Return book 5.Search book 6.Member list");
  336. puts("7.Logout 8.Exit program");
  337. int booknum;
  338.  
  339. scanf("%d",&foradmin);
  340. switch(foradmin)
  341. {
  342. case 1:
  343. {
  344. head=create_linkedlist_book(line_of_file("book.txt"));
  345. download_linkedlist_book(head);
  346. sort_linkedlist_book(head);
  347. //upload_linkedlist_book(head);
  348. booknum=Readbookname_linkedlist_book(head,line_of_file("book.txt"));
  349. Register_linkedlist_book(booknum,head);
  350. head=create_linkedlist_book(line_of_file("book.txt"));
  351. download_linkedlist_book(head);
  352. sort_linkedlist_book(head);
  353. upload_linkedlist_book(head);
  354.  
  355.  
  356. break;
  357. }
  358.  
  359. case 2:
  360. {
  361.  
  362. head=create_linkedlist_book(line_of_file("book.txt"));
  363. download_linkedlist_book(head);
  364. sort_linkedlist_book(head);
  365. delete_linkedlist_book(head);
  366. break;
  367. }
  368. case 3:
  369. {
  370.  
  371. head=create_linkedlist_book(line_of_file("book.txt"));
  372. download_linkedlist_book(head);
  373. sort_linkedlist_book(head);
  374.  
  375. int temp_one_or_two=0;
  376. int borrow_identifier;
  377.  
  378. //IDD is USERID
  379. puts(">>>>BOOK BORROW<<<<<<");
  380. puts("1.search by bookname 2.search by book_ISBN");
  381.  
  382. scanf("%d",&temp_one_or_two);
  383. if(temp_one_or_two == 1)
  384. {
  385. borrow_identifier=borrow_search_linkedlist_book_bookname(head);
  386.  
  387. if (borrow_identifier==0)
  388. break;
  389.  
  390.  
  391. borrow_input_linkedlist(head);
  392.  
  393. }
  394.  
  395.  
  396. if(temp_one_or_two==2)
  397. {
  398. borrow_identifier= borrow_search_linkedlist_book_ISBN(head);
  399.  
  400. if (borrow_identifier==0)
  401. break;
  402.  
  403.  
  404. borrow_input_linkedlist(head);
  405.  
  406. }
  407.  
  408. break;
  409.  
  410. }
  411. case 4:
  412. {
  413.  
  414. int idforstudent;
  415. system("clear");
  416. puts("학 번 입력해라 ~~~");
  417. scanf("%d",&idforstudent);
  418.  
  419.  
  420. BORROW=borrow_create_linkedlist(line_of_file("borrow.txt"));
  421. return_download(BORROW);
  422.  
  423.  
  424. head=create_linkedlist_book(line_of_file("book.txt"));
  425. download_linkedlist_book(head);
  426.  
  427.  
  428.  
  429. print_all_book(idforstudent,head,BORROW);
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436. break;
  437. }
  438. case 5:
  439. {
  440. int menuselect=0;
  441. system("clear");
  442. head=create_linkedlist_book(line_of_file("book.txt"));
  443. download_linkedlist_book(head);
  444. sort_linkedlist_book(head);
  445. puts("1.Search with book name 2.Search with publisher 3.Search with ISBN");
  446. puts("4.Search with author 5.search all 6.previous menu");
  447. scanf("%d",&menuselect);
  448.  
  449. switch(menuselect)
  450. {
  451. case 1:
  452. {
  453. search_linkedlist_book_bookname(head);
  454. break;
  455. }
  456. case 2:
  457. {
  458. search_linkedlist_book_publisher(head);
  459. break;
  460. }
  461. case 3:
  462. {
  463. search_linkedlist_book_ISBN(head);
  464. break;
  465. }
  466. case 4:
  467. {
  468. search_linkedlist_book_author(head);
  469. break;
  470. }
  471. case 5:
  472. {
  473. search_linkedlist_book_all(head);
  474. break;
  475. }
  476. case 6:
  477. {
  478. break;
  479. }
  480. }
  481.  
  482. break;
  483. }
  484.  
  485.  
  486.  
  487. case 6:
  488. {
  489. int forclient=0;
  490. system("clear");
  491. puts(">>>>>>>>>LIST OF CLIENTS<<<<<<<<<<");
  492. puts("1.Search with name 2.Search with ID");
  493. puts("3.Print all 4.Previous menu");
  494. scanf("%d",&forclient);
  495. if(forclient==1)
  496. {
  497.  
  498. CLIENT=create_NOINPUT_linkedlist_client(line_of_file("client.txt")); //Create , INPUT VALUES.
  499. download_linkedlist_client(CLIENT);
  500. sort_linkedlist_client(CLIENT);
  501. upload_linkedlist_client(CLIENT);
  502. search_by_clientname(CLIENT);
  503.  
  504. }
  505.  
  506. if(forclient==2)
  507. {
  508. CLIENT=create_NOINPUT_linkedlist_client(line_of_file("client.txt")); //Create , INPUT VALUES.
  509. download_linkedlist_client(CLIENT);
  510. sort_linkedlist_client(CLIENT);
  511. upload_linkedlist_client(CLIENT);
  512. search_by_ID(CLIENT);
  513. }
  514.  
  515. if(forclient==3)
  516. {
  517. CLIENT=create_NOINPUT_linkedlist_client(line_of_file("client.txt")); //Create , INPUT VALUES.
  518. download_linkedlist_client(CLIENT);
  519. sort_linkedlist_client(CLIENT);
  520. upload_linkedlist_client(CLIENT);
  521. Print_all_client(CLIENT);
  522. }
  523.  
  524. if(forclient==4)
  525. {
  526.  
  527. break;
  528. }
  529.  
  530.  
  531. break;
  532. }
  533.  
  534. case 7:
  535. {
  536. break;
  537. }
  538. case 8:
  539. {
  540. return 0;
  541. }
  542.  
  543.  
  544.  
  545. }
  546. if(foradmin==7)
  547. break;
  548.  
  549. }//while
  550.  
  551. } //if
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559. break;
  560. }//case2
  561.  
  562. case 3:
  563. break;
  564.  
  565.  
  566. }//switch
  567.  
  568. }//while
  569.  
  570. return 0;
  571. }//main
  572.  
  573. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  574. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  575. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  576.  
  577.  
  578. client* create_linkedlist_client(int n)
  579. {
  580.  
  581. client* head=NULL;
  582. client* temp=NULL;
  583. client* p = NULL;
  584.  
  585. char temp2[100],temp3[100],temp4[100],temp5[100];
  586. int i;
  587.  
  588. scanf("%d|%[^|]|%[^|]|%[^|]|%s",&temp1,temp2,temp3,temp4,temp5);
  589.  
  590. for(i=0;i<n;i++)
  591. {
  592. temp =(client*)malloc(sizeof(client));
  593.  
  594.  
  595. temp->ID=temp1; strcpy(temp->PW,temp2); strcpy(temp->NAME,temp3);
  596. strcpy(temp->ADDRESS,temp4); strcpy(temp->PNUM,temp5);
  597.  
  598. temp->next=NULL;
  599.  
  600.  
  601.  
  602. if(head==NULL)
  603. {
  604. head=temp;
  605. }
  606. else
  607. {
  608. p=head;
  609. while(p->next != NULL)
  610. p=p->next;
  611. p->next = temp;
  612. }
  613. }
  614. return head;
  615. }
  616.  
  617.  
  618.  
  619. void upload_linkedlist_client(client* head)
  620. {
  621. client* p=head;
  622. FILE *f=fopen("client.txt","w");
  623.  
  624. while(p !=NULL)
  625. {
  626. fprintf(f,"%d|%s|%s|%s|%s\n",p->ID,p->PW,p->NAME,p->ADDRESS,p->PNUM);
  627. p = p->next;
  628. }
  629. fclose(f);
  630. }
  631.  
  632.  
  633.  
  634.  
  635. void download_linkedlist_client(client* head)
  636. {
  637. client* p=head;
  638. FILE *f=fopen("client.txt","r");
  639.  
  640. while(p !=NULL)
  641. {
  642. fscanf(f,"%d|%[^|]|%[^|]|%[^|]|%s\n",&(p->ID),p->PW,p->NAME,p->ADDRESS,p->PNUM);
  643. p = p->next;
  644. }
  645. fclose(f);
  646. }
  647.  
  648. void sort_linkedlist_client(client* head)
  649. {
  650. client *i,*j;
  651. int temp1;
  652. char temp2[100],temp3[100],temp4[100],temp5[100];
  653.  
  654. for(i=head;i->next!=NULL;i=i->next)
  655. {
  656. for(j=i->next; j!=NULL; j=j->next)
  657. {
  658. if(i->ID > j->ID)
  659. {
  660. temp1 = i->ID;
  661. strcpy(temp2,i->PW); strcpy(temp3,i->NAME); strcpy(temp4,i->ADDRESS); strcpy(temp5,i->PNUM);
  662. i->ID=j->ID;
  663. strcpy(i->PW,j->PW); strcpy(i->NAME,j->NAME); strcpy(i->ADDRESS,j->ADDRESS); strcpy(i->PNUM,j->PNUM);
  664. j->ID=temp1; strcpy(j->PW,temp2); strcpy(j->NAME,temp3); strcpy(j->ADDRESS,temp4); strcpy(j->PNUM,temp5);
  665. }
  666. }
  667. }
  668. }
  669.  
  670.  
  671.  
  672.  
  673.  
  674. int line_of_file(char * name)
  675. {
  676. FILE *fp;
  677. char buf[1024];
  678. int i;
  679.  
  680. fp=fopen(name ,"r");
  681. for (i=0,buf[1022]=0; fgets(buf,1024,fp); buf[1022]=0)
  682. (buf[1022] && buf[1022] != '\n') ? : i++;
  683.  
  684. fclose(fp);
  685. return i;
  686. }
  687.  
  688.  
  689. void duplicate_inspection_client(client* head)
  690. {
  691.  
  692. client* p=head;
  693.  
  694. while(p->next!=NULL)
  695. {
  696. if(temp1 == p->ID)
  697. {
  698. system("clear");
  699. puts("ERROR!! Have a Same ID");
  700. puts("Going back to main menu in 5sec...");
  701. identifier=1;
  702. Sleep(5000);
  703. break;
  704. }
  705.  
  706. p = p->next;
  707. }
  708.  
  709. }
  710.  
  711.  
  712. int login(client* head,int id,char* pw)
  713. {
  714.  
  715. client* p=head;
  716.  
  717. while(p != NULL)
  718. {
  719.  
  720. if((id == p->ID)==1 && strcmp(pw,p->PW)==0)
  721. return 1;
  722.  
  723.  
  724. p = p->next;
  725.  
  726. }
  727. return 0;
  728. }
  729.  
  730. client* create_linkedlist_client_login(int n)
  731. {
  732.  
  733. int i;
  734. client* head=NULL;
  735. client* temp=NULL;
  736. client* p = NULL;
  737.  
  738. for(i=0;i<n;i++)
  739. {
  740. temp =(client*)malloc(sizeof(client));
  741. temp->next=NULL;
  742.  
  743. if(head==NULL)
  744. {
  745. head=temp;
  746. }
  747. else
  748. {
  749. p=head;
  750. while(p->next != NULL)
  751. p=p->next;
  752. p->next = temp;
  753. }
  754. }
  755. return head;
  756. }
  757.  
  758.  
  759. void change_my_info(client* head,int n)
  760. {
  761. client* p=head;
  762.  
  763. char tempPW[100],tempADDRESS[100],tempPNUM[100];
  764.  
  765. system("clear");
  766. puts("Enter new PW");
  767. while(getchar()!='\n');
  768. scanf("%[^\n]",tempPW);
  769. puts("Enter new ADDRESS");
  770. while(getchar()!='\n');
  771. scanf("%[^\n]",tempADDRESS);
  772. puts("Enter new PNUM");
  773. while(getchar()!='\n');
  774. scanf("%[^\n]",tempPNUM);
  775.  
  776. FILE* f=fopen("client.txt","w");
  777. while(p!=NULL)
  778. {
  779. if(n==p->ID)
  780. fprintf(f,"%d|%s|%s|%s|%s\n",p->ID,tempPW,p->NAME,tempADDRESS,tempPNUM);
  781. if(n!=p->ID)
  782. fprintf(f,"%d|%s|%s|%s|%s\n",p->ID,p->PW,p->NAME,p->ADDRESS,p->PNUM);
  783.  
  784. p=p->next;
  785. }
  786.  
  787. fclose(f);
  788. }
  789.  
  790. void withdrawal(client* head,int n)
  791. {
  792. int repeat_value=1;
  793.  
  794. client* p=head;
  795.  
  796. while(1)
  797. {
  798. if(p->ID==n)
  799. {
  800.  
  801. printf("%d|%s|%s|%s|%s\n",p->ID,p->PW,p->NAME,p->ADDRESS,p->PNUM);
  802. puts("Delete in 5sec");
  803. Sleep(5000);
  804.  
  805. p=head;
  806.  
  807. FILE* f=fopen("client.txt","w");
  808. int i=1;
  809. while(p!=NULL)
  810. {
  811.  
  812. if(i!=repeat_value)
  813. fprintf(f,"%d|%s|%s|%s|%s\n",p->ID,p->PW,p->NAME,p->ADDRESS,p->PNUM);
  814.  
  815. ++i;
  816. p=p->next;
  817. }
  818. fclose(f);
  819. break;
  820. }
  821. repeat_value++;
  822. p=p->next;
  823. }
  824.  
  825.  
  826. }
  827.  
  828.  
  829.  
  830. ///////////////////////////////////////////////////////////////////////////////////////////////
  831.  
  832. void search_linkedlist_book_ISBN(book* head)
  833. {
  834. long long tempforISBN;
  835. int ISBN_identifier=0;
  836. system("clear");
  837. book* p=head;
  838. puts("Enter ISBN");
  839. scanf("%lld",&tempforISBN);
  840. system("clear");
  841. while(p != NULL)
  842. {
  843. if(tempforISBN == p->ISBN)
  844. {
  845.  
  846. printf("%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  847. ISBN_identifier=1;
  848.  
  849. }
  850.  
  851. p = p->next;
  852. }
  853.  
  854. if(ISBN_identifier==0)
  855. {
  856. system("clear");
  857. puts("Wrong! Going back to menu in 3sec");
  858. Sleep(3000);
  859. }
  860. if(ISBN_identifier==1)
  861. {
  862. puts("Going back to menu in 5sec");
  863. Sleep(5000);
  864. }
  865.  
  866. }
  867.  
  868.  
  869.  
  870. void search_linkedlist_book_bookname(book* head)
  871. {
  872. char tempforbookname[50];
  873. int bookname_identifier=0;
  874. system("clear");
  875. book* p=head;
  876. puts("Enter bookname");
  877. while(getchar()!='\n');
  878. scanf("%[^\n]",tempforbookname);
  879. system("clear");
  880. while(p != NULL)
  881. {
  882. if(strcmp(tempforbookname,p->book_name)==0)
  883. {
  884.  
  885. printf("%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  886. bookname_identifier=1;
  887.  
  888. }
  889.  
  890. p = p->next;
  891. }
  892.  
  893.  
  894. if(bookname_identifier==0)
  895. {
  896. system("clear");
  897. puts("Wrong! Going back to menu in 3sec");
  898. Sleep(3000);
  899. }
  900. if(bookname_identifier==1)
  901. {
  902. puts("Going back to menu in 5sec");
  903. Sleep(5000);
  904. }
  905.  
  906. }
  907.  
  908. void search_linkedlist_book_publisher(book* head)
  909. {
  910. char temp_book_publisher[50];
  911. int bookpublisher_identifier=0;
  912. system("clear");
  913. book* p=head;
  914. puts("Enter publisher");
  915. while(getchar()!='\n');
  916. scanf("%[^\n]",temp_book_publisher);
  917. system("clear");
  918. while(p != NULL)
  919. {
  920. if(strcmp(temp_book_publisher,p->publisher)==0)
  921. {
  922.  
  923. printf("%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  924. bookpublisher_identifier=1;
  925.  
  926. }
  927.  
  928. p = p->next;
  929. }
  930.  
  931.  
  932. if(bookpublisher_identifier==0)
  933. {
  934. system("clear");
  935. puts("Wrong! Going back to menu in 3sec");
  936. Sleep(3000);
  937. }
  938. if(bookpublisher_identifier==1)
  939. {
  940. puts("Going back to menu in 5sec");
  941. Sleep(5000);
  942. }
  943.  
  944. }
  945.  
  946.  
  947. void search_linkedlist_book_author(book* head)
  948. {
  949. char tempforbookauthor[50];
  950. int bookauthor_identifier=0;
  951. system("clear");
  952. book* p=head;
  953. puts("Enter bookname");
  954. while(getchar()!='\n');
  955. scanf("%[^\n]",tempforbookauthor);
  956. system("clear");
  957. while(p != NULL)
  958. {
  959. if(strcmp(tempforbookauthor,p->author)==0)
  960. {
  961.  
  962. printf("%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  963. bookauthor_identifier=1;
  964.  
  965. }
  966.  
  967. p = p->next;
  968. }
  969.  
  970.  
  971. if(bookauthor_identifier==0)
  972. {
  973. system("clear");
  974. puts("Wrong! Going back to menu in 3sec");
  975. Sleep(3000);
  976. }
  977. if(bookauthor_identifier==1)
  978. {
  979. puts("Going back to menu in 5sec");
  980. Sleep(5000);
  981. }
  982.  
  983. }
  984. void search_linkedlist_book_all(book* head)
  985. {
  986. system("clear");
  987. book* p=head;
  988.  
  989. while(p != NULL)
  990. {
  991. printf("%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  992. p = p->next;
  993. }
  994.  
  995. puts("Going back to menu in 5sec");
  996. Sleep(5000);
  997. }
  998.  
  999.  
  1000. book* create_linkedlist_book(int n)
  1001. {
  1002.  
  1003. book* head=NULL;
  1004. book* temp=NULL;
  1005. book* p = NULL;
  1006.  
  1007.  
  1008. int i;
  1009.  
  1010.  
  1011. for(i=0;i<n;i++)
  1012. {
  1013. temp =(book*)malloc(sizeof(book));
  1014. temp->next=NULL;
  1015.  
  1016.  
  1017.  
  1018. if(head==NULL)
  1019. {
  1020. head=temp;
  1021. }
  1022. else
  1023. {
  1024. p=head;
  1025. while(p->next != NULL)
  1026. p=p->next;
  1027. p->next = temp;
  1028. }
  1029. }
  1030. return head;
  1031. }
  1032.  
  1033. void download_linkedlist_book(book* head)
  1034. {
  1035. book* p=head;
  1036.  
  1037. FILE *f=fopen("book.txt","r");
  1038.  
  1039. while(p !=NULL)
  1040. {
  1041. fscanf(f,"%d|%[^|]|%[^|]|%[^|]|%lld|%[^|]|%s\n",&(p->book_num),p->book_name,p->publisher,p->author,&(p->ISBN),p->book_address,p->Y_N);
  1042. p = p->next;
  1043. }
  1044. fclose(f);
  1045. }
  1046.  
  1047. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1048.  
  1049. void sort_linkedlist_book(book* head)
  1050. {
  1051. book *i,*j;
  1052. int temp1;
  1053. long long temp5;
  1054. char temp2[100],temp3[100],temp4[100],temp6[100],temp7[2];
  1055.  
  1056. for(i=head;i->next!=NULL;i=i->next)
  1057. {
  1058. for(j=i->next; j!=NULL; j=j->next)
  1059. {
  1060. if(i->ISBN > j->ISBN)
  1061. {
  1062. temp1 = i->book_num; temp5 = i->ISBN;
  1063. strcpy(temp2,i->book_name); strcpy(temp3,i->publisher); strcpy(temp4,i->author); strcpy(temp6,i->book_address); strcpy(temp7,i->Y_N);
  1064.  
  1065. i->book_num = j->book_num; i->ISBN = j->ISBN;
  1066. strcpy(i->book_name,j->book_name); strcpy(i->publisher,j->publisher);strcpy(i->author,j->author);strcpy(i->book_address,j->book_address);strcpy(i->Y_N,j->Y_N);
  1067.  
  1068. j->book_num = temp1; j->ISBN = temp5;
  1069. strcpy(j->book_name,temp2); strcpy(j->publisher,temp3); strcpy(j->author,temp4); strcpy(j->book_address,temp6); strcpy(j->Y_N,temp7);
  1070. }
  1071. }
  1072. }
  1073. }
  1074.  
  1075.  
  1076.  
  1077. void upload_linkedlist_book(book* head)
  1078. {
  1079. book* p=head;
  1080. FILE *f=fopen("book.txt","w");
  1081.  
  1082. while(p !=NULL)
  1083. {
  1084. fprintf(f,"%d|%s|%s|%s|%ld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1085. p = p->next;
  1086. }
  1087. fclose(f);
  1088. }
  1089.  
  1090. void Register_linkedlist_book(int booknum,book* head)
  1091. {
  1092. book* p=head;
  1093. FILE *f=fopen("book.txt","a");
  1094. char temp1[100],temp2[100],temp3[100],temp5[100];
  1095. long long temp4;
  1096.  
  1097. puts("Book name:");
  1098. getchar();
  1099. scanf("%[^\n]",temp1);
  1100. puts("Publisher:");
  1101. getchar();
  1102. scanf("%[^\n]",temp2);
  1103. puts("Author:");
  1104. getchar();
  1105. scanf("%[^\n]",temp3);
  1106. puts("ISBN:");
  1107. scanf("%lld",&temp4);
  1108. puts("Book adrress:");
  1109. getchar();
  1110. scanf("%[^\n]",temp5);
  1111.  
  1112. fprintf(f,"%d|%s|%s|%s|%ld|%s|Y\n",booknum+1,temp1,temp2,temp3,temp4,temp5);
  1113.  
  1114.  
  1115. fclose(f);
  1116. }
  1117. int Readbookname_linkedlist_book(book* head,int length)
  1118. {
  1119. book* p=head;
  1120.  
  1121. for(int i=0;i<length;i++)
  1122. {
  1123. if(i==length-1)
  1124. {
  1125. return p->book_num;
  1126. }
  1127. p=p->next;
  1128. }
  1129. return 0;
  1130.  
  1131. }
  1132.  
  1133. void delete_linkedlist_book(book* head)
  1134. {
  1135. int menuselect;
  1136. long long tempISBN;
  1137. char tempbookname[100];
  1138. int repeat_value=1;
  1139.  
  1140. book* p=head;
  1141. puts("1.Delete by book name");
  1142. puts("2.Delete by ISBN");
  1143. scanf("%d",&menuselect);
  1144.  
  1145. if(menuselect==1)
  1146. {
  1147. puts("Enter book name");
  1148. while(getchar() != '\n');
  1149. scanf("%[^\n]",tempbookname);
  1150. while(1)
  1151. {
  1152. if(strcmp(p->book_name,tempbookname)==0)
  1153. {
  1154. if(strcmp(p->Y_N,"N")==0)
  1155. {
  1156. puts("YOU CAN`T DELETE THIS BOOK");
  1157. puts("Turn back to menu in 5sec..");
  1158. Sleep(5000);
  1159. break;
  1160. }
  1161. printf("%d|%s|%s|%s|%ld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1162. puts("Delete in 5sec");
  1163. Sleep(5000);
  1164.  
  1165. p=head;
  1166. FILE* f=fopen("book.txt","w");
  1167. int i=1;
  1168. while(p!=NULL)
  1169. {
  1170.  
  1171. if(i!=repeat_value)
  1172. fprintf(f,"%d|%s|%s|%s|%ld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1173.  
  1174. ++i;
  1175. p=p->next;
  1176. }
  1177. fclose(f);
  1178. break;
  1179. }
  1180. repeat_value++;
  1181. p=p->next;
  1182. }
  1183.  
  1184.  
  1185. }
  1186.  
  1187.  
  1188.  
  1189. if(menuselect==2)
  1190. {
  1191. puts("Enter ISBN");
  1192. scanf("%lld",&tempISBN);
  1193. while(1)
  1194. {
  1195. if(p->ISBN==tempISBN)
  1196. {
  1197. if(strcmp(p->Y_N,"N")==0)
  1198. {
  1199. puts("YOU CAN`T DELETE THIS BOOK");
  1200. puts("Turn back to menu in 5sec..");
  1201. Sleep(5000);
  1202. break;
  1203. }
  1204. printf("%d|%s|%s|%s|%ld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1205. puts("Delete in 5sec");
  1206. Sleep(5000);
  1207.  
  1208. p=head;
  1209. FILE* f=fopen("book.txt","w");
  1210. int i=1;
  1211. while(p!=NULL)
  1212. {
  1213.  
  1214. if(i!=repeat_value)
  1215. fprintf(f,"%d|%s|%s|%s|%ld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1216.  
  1217. ++i;
  1218. p=p->next;
  1219. }
  1220. fclose(f);
  1221. break;
  1222. }
  1223. repeat_value++;
  1224. p=p->next;
  1225. }
  1226.  
  1227.  
  1228. }
  1229. }
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237. client* create_NOINPUT_linkedlist_client(int n)
  1238. {
  1239.  
  1240. client* head=NULL;
  1241. client* temp=NULL;
  1242. client* p = NULL;
  1243. int i;
  1244.  
  1245. for(i=0;i<n;i++)
  1246. {
  1247. temp =(client*)malloc(sizeof(client));
  1248. temp->next=NULL;
  1249.  
  1250. if(head==NULL)
  1251. {
  1252. head=temp;
  1253. }
  1254. else
  1255. {
  1256. p=head;
  1257. while(p->next != NULL)
  1258. p=p->next;
  1259. p->next = temp;
  1260. }
  1261. }
  1262. return head;
  1263. }
  1264.  
  1265.  
  1266. client* search_by_clientname(client* head)
  1267. {
  1268. system("clear");
  1269. char temp_clientname[100];
  1270. puts("Enter client name");
  1271. while(getchar()!='\n');
  1272. scanf("%[^\n]",temp_clientname);
  1273.  
  1274. client* p=head;
  1275. while(p!=NULL)
  1276. {
  1277. if(strcmp(p->NAME,temp_clientname)==0)
  1278. {
  1279. printf("%d|%s|%s|%s\n",p->ID,p->NAME,p->ADDRESS,p->PNUM);
  1280. }
  1281. p=p->next;
  1282. }
  1283. puts("Going back to previous menu in 5sec...");
  1284. Sleep(5000);
  1285. }
  1286.  
  1287.  
  1288. client* search_by_ID(client* head)
  1289. {
  1290. system("clear");
  1291. int temp_clientID;
  1292. puts("Enter client ID");
  1293. scanf("%d",&temp_clientID);
  1294.  
  1295. client* p=head;
  1296. while(p!=NULL)
  1297. {
  1298. if(p->ID==temp_clientID)
  1299. {
  1300. printf("%d|%s|%s|%s\n",p->ID,p->NAME,p->ADDRESS,p->PNUM);
  1301. }
  1302. p=p->next;
  1303. }
  1304. puts("Going back to previous menu in 5sec...");
  1305. Sleep(5000);
  1306. }
  1307.  
  1308. client* Print_all_client(client* head)
  1309. {
  1310. system("clear");
  1311. puts(">>PRINT ALL<<");
  1312.  
  1313. client* p=head;
  1314. while(p!=NULL)
  1315. {
  1316. printf("%d|%s|%s|%s\n",p->ID,p->NAME,p->ADDRESS,p->PNUM);
  1317. p=p->next;
  1318. }
  1319. puts("Going back to previous menu in 5sec...");
  1320. Sleep(5000);
  1321.  
  1322. }
  1323.  
  1324.  
  1325. borrow* borrow_create_linkedlist(int n) //NO INPUT JUST CREATE
  1326. {
  1327.  
  1328. borrow* head=NULL;
  1329. borrow* temp=NULL;
  1330. borrow* p = NULL;
  1331. int i;
  1332. for(i=0;i<n;i++)
  1333. {
  1334. temp=(borrow*)malloc(sizeof(borrow));
  1335. temp->next=NULL;
  1336. if(head==NULL)
  1337. {
  1338. head=temp;
  1339. }
  1340. else
  1341. {
  1342. p=head;
  1343. while(p->next != NULL)
  1344. p=p->next;
  1345. p->next = temp;
  1346. }
  1347. }
  1348. return head;
  1349. }
  1350.  
  1351.  
  1352. borrow* borrow_input_linkedlist(book* head)
  1353. {
  1354. int studentID,bookID;
  1355. int newmonth;
  1356. int newday;
  1357. time_t now;
  1358. char temp[33];
  1359. char ifsunday[6]={temp[0],temp[1],temp[2]};
  1360. time(&now);
  1361.  
  1362. strcpy(temp,ctime(&now));
  1363.  
  1364. char temp2[10]={temp[4],temp[5],temp[6]};
  1365.  
  1366. if(!strcmp("Jan",temp2))
  1367. strcpy(temp2,"1");
  1368.  
  1369. if(!strcmp("Feb",temp2))
  1370. strcpy(temp2,"2");
  1371.  
  1372. if(!strcmp("Mar",temp2))
  1373. strcpy(temp2,"3");
  1374.  
  1375. if(!strcmp("Apr",temp2))
  1376. strcpy(temp2,"4");
  1377.  
  1378. if(!strcmp("May",temp2))
  1379. strcpy(temp2,"5");
  1380.  
  1381. if(!strcmp("Jun",temp2))
  1382. strcpy(temp2,"6");
  1383.  
  1384. if(!strcmp("Jul",temp2))
  1385. strcpy(temp2,"7");
  1386.  
  1387. if(!strcmp("Aug",temp2))
  1388. strcpy(temp2,"8");
  1389.  
  1390. if(!strcmp("Sep",temp2))
  1391. strcpy(temp2,"9");
  1392.  
  1393. if(!strcmp("Oct",temp2))
  1394. strcpy(temp2,"10");
  1395.  
  1396. if(!strcmp("Nov",temp2))
  1397. strcpy(temp2,"11");
  1398.  
  1399. if(!strcmp("Dec",temp2))
  1400. strcpy(temp2,"12");
  1401.  
  1402.  
  1403. char temp3[10]={temp[8],temp[9]};
  1404.  
  1405. if(!strcmp("01",temp3))
  1406. strcpy(temp3,"1");
  1407.  
  1408. if(!strcmp("02",temp3))
  1409. strcpy(temp3,"2");
  1410.  
  1411. if(!strcmp("03",temp3))
  1412. strcpy(temp3,"3");
  1413.  
  1414. if(!strcmp("04",temp3))
  1415. strcpy(temp3,"4");
  1416.  
  1417. if(!strcmp("05",temp3))
  1418. strcpy(temp3,"5");
  1419.  
  1420. if(!strcmp("06",temp3))
  1421. strcpy(temp3,"6");
  1422.  
  1423. if(!strcmp("07",temp3))
  1424. strcpy(temp3,"7");
  1425.  
  1426. if(!strcmp("08",temp3))
  1427. strcpy(temp3,"8");
  1428.  
  1429. if(!strcmp("09",temp3))
  1430. strcpy(temp3,"9");
  1431.  
  1432. //temp2 == 월
  1433. //temp3 == 일
  1434.  
  1435. /////////////////////////
  1436.  
  1437.  
  1438. newmonth=atoi(temp2);
  1439. newday=atoi(temp3);
  1440.  
  1441.  
  1442. if(!strcmp("Sun",ifsunday))
  1443. newday+=31;
  1444.  
  1445.  
  1446. if(strcmp("Sun",ifsunday))
  1447. newday+=30;
  1448.  
  1449. if(newmonth==12)
  1450. {
  1451. newmonth=1;
  1452. newday%=31;
  1453. }
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461. puts("학번을 입력하세요");
  1462. scanf("%d",&studentID);
  1463.  
  1464. puts("도서 번호를 입력하세요");
  1465. scanf("%d",&bookID);
  1466.  
  1467.  
  1468. FILE *ff=fopen("book.txt","w");
  1469. book* p=head;
  1470. while(p!=NULL)
  1471. {
  1472. if(bookID==p->book_num)
  1473. fprintf(ff,"%d|%s|%s|%s|%lld|%s|N\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address);
  1474.  
  1475.  
  1476. if(bookID!=p->book_num)
  1477. fprintf(ff,"%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1478.  
  1479. p=p->next;
  1480. }
  1481.  
  1482. fclose(ff);
  1483.  
  1484.  
  1485. FILE *f=fopen("borrow.txt","a");
  1486.  
  1487. //2018년 12월은 31일
  1488. fprintf(f,"%d|%d|%s%s|%d%d\n",studentID,bookID,temp2,temp3,newmonth,newday);
  1489.  
  1490.  
  1491.  
  1492.  
  1493. fclose(f);
  1494.  
  1495. }
  1496.  
  1497.  
  1498. int borrow_search_linkedlist_book_bookname(book* head)
  1499. {
  1500. char tempforbookname[50];
  1501. int bookname_identifier=0;
  1502. int temp;
  1503. system("clear");
  1504. book* p=head;
  1505. puts("Enter bookname");
  1506. while(getchar()!='\n');
  1507. scanf("%[^\n]",tempforbookname);
  1508. system("clear");
  1509. while(p != NULL)
  1510. {
  1511. if(strcmp(tempforbookname,p->book_name)==0)
  1512. {
  1513.  
  1514. printf("%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1515. puts("if you enter 1 , Borrow this book.");
  1516. puts("if you enter other number , exit ");
  1517. scanf("%d",&temp);
  1518. if(temp==1)
  1519. {
  1520. return p->book_num;
  1521. }
  1522. if(temp!=1)
  1523. {
  1524. return 0;
  1525. }
  1526. bookname_identifier=1;
  1527.  
  1528. }
  1529.  
  1530. p = p->next;
  1531. }
  1532. }
  1533.  
  1534.  
  1535.  
  1536. int borrow_search_linkedlist_book_ISBN(book* head)
  1537. {
  1538. long long tempforISBN;
  1539. int ISBN_identifier=0;
  1540. int temp;
  1541. system("clear");
  1542. book* p=head;
  1543. puts("ISBN을 입력하세요");
  1544.  
  1545. scanf("%lld",&tempforISBN);
  1546. system("clear");
  1547. while(p != NULL)
  1548. {
  1549. if(tempforISBN==p->ISBN)
  1550. {
  1551. printf("%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1552. puts("if you enter 1 , Borrow this book.");
  1553. puts("if you enter other number , exit ");
  1554. scanf("%d",&temp);
  1555.  
  1556. if(temp==1)
  1557. {
  1558. return p->book_num;
  1559. }
  1560. if(temp!=1)
  1561. {
  1562. return 0;
  1563. }
  1564. ISBN_identifier=1;
  1565.  
  1566. }
  1567.  
  1568. p = p->next;
  1569. }
  1570. }
  1571.  
  1572.  
  1573.  
  1574.  
  1575. void return_download(borrow* head)
  1576. {
  1577. borrow* p=head;
  1578. FILE *f=fopen("borrow.txt","r");
  1579.  
  1580. while(p !=NULL)
  1581. {
  1582. fscanf(f,"%d|%d|%ld|%ld\n",&(p->stu_num),&(p->book_num),&(p->b_date),&(p->r_date));
  1583. p = p->next;
  1584. }
  1585. fclose(f);
  1586.  
  1587. }
  1588.  
  1589.  
  1590. void print_all_book(int ID,book* head,borrow* headhead)
  1591. {
  1592. puts(">>>내 대여목록<<<");
  1593.  
  1594. book* p=head;
  1595. borrow* q=headhead;
  1596. int bookIDTEMP[100]={0};
  1597. long borrowdate[100];
  1598. long returndate[100];
  1599. char bookNAMETEMP[100][100];
  1600. int borrowbooknum;
  1601. int i=0;
  1602. int cnt=0;
  1603. int t=0;
  1604. char YorN;
  1605.  
  1606.  
  1607. while(q != NULL)
  1608. {
  1609. if(ID==q->stu_num)
  1610. {
  1611. bookIDTEMP[i] = q->book_num;
  1612. borrowdate[i] = q->b_date;
  1613. returndate[i] = q->r_date;
  1614. i += 1;
  1615. cnt=i;
  1616. }
  1617. q=q->next;
  1618. }
  1619.  
  1620.  
  1621. for(i=0; i<cnt; i++)
  1622. {
  1623. p=head;
  1624. while(p!=NULL)
  1625. {
  1626. if(bookIDTEMP[i] == p->book_num)
  1627. {
  1628. strcpy(&bookNAMETEMP[t][0],p->book_name);
  1629. ++t;
  1630. }
  1631.  
  1632. p=p->next;
  1633.  
  1634. }
  1635. }
  1636.  
  1637. i=0;
  1638. t=0;
  1639.  
  1640.  
  1641. while(bookIDTEMP[i] != 0)
  1642. {
  1643. printf("도서번호:%d\n",bookIDTEMP[i]);
  1644. printf("도서명:%s\n",&bookNAMETEMP[t][0]);
  1645. printf("대여일자:%ld\n",borrowdate[i]);
  1646. printf("반납일자:%ld\n",returndate[i]);
  1647. puts("\n");
  1648. i++;
  1649. t++;
  1650. }
  1651.  
  1652. puts("반납할 도서번호를 입력하세요:");
  1653. scanf("%d",&borrowbooknum);
  1654.  
  1655. q=headhead;
  1656. while(q!=NULL)
  1657. {
  1658. if(borrowbooknum==q->book_num)
  1659. {
  1660. puts("도서 반납 처리를 할까요? 하고싶으면 Y");
  1661. break;
  1662. }
  1663. q=q->next;
  1664. }
  1665.  
  1666.  
  1667. scanf(" %c",&YorN);
  1668.  
  1669.  
  1670. if(YorN='Y')
  1671. {
  1672. FILE *f= fopen("borrow.txt","w");
  1673. q=headhead;
  1674.  
  1675.  
  1676. while(q!=NULL)
  1677. {
  1678.  
  1679. if(borrowbooknum != q->book_num)
  1680. fprintf(f,"%d|%d|%ld|%ld\n",q->stu_num,q->book_num,q->b_date,q->r_date);
  1681.  
  1682. q=q->next;
  1683. }
  1684. fclose(f);
  1685.  
  1686.  
  1687. FILE *ff=fopen("book.txt","w");
  1688. p=head;
  1689. while(p!=NULL)
  1690. {
  1691. if(borrowbooknum==p->book_num)
  1692. fprintf(ff,"%d|%s|%s|%s|%lld|%s|Y\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address);
  1693.  
  1694.  
  1695. if(borrowbooknum!=p->book_num)
  1696. fprintf(ff,"%d|%s|%s|%s|%lld|%s|%s\n",p->book_num,p->book_name,p->publisher,p->author,p->ISBN,p->book_address,p->Y_N);
  1697.  
  1698. p=p->next;
  1699. }
  1700.  
  1701. fclose(ff);
  1702.  
  1703. }
  1704. }
  1705.  
  1706.  
  1707.  
  1708.  
  1709. void Print_all_book(int ID,book* head,borrow* headhead)
  1710. {
  1711. puts(">>>내 대여목록<<<");
  1712.  
  1713. book* p=head;
  1714. borrow* q=headhead;
  1715. int bookIDTEMP[100]={0};
  1716. long borrowdate[100];
  1717. long returndate[100];
  1718. char bookNAMETEMP[100][100];
  1719. int borrowbooknum;
  1720. int i=0;
  1721. int cnt=0;
  1722. int t=0;
  1723. char YorN;
  1724.  
  1725.  
  1726. while(q != NULL)
  1727. {
  1728. if(ID==q->stu_num)
  1729. {
  1730. bookIDTEMP[i] = q->book_num;
  1731. borrowdate[i] = q->b_date;
  1732. returndate[i] = q->r_date;
  1733. i += 1;
  1734. cnt=i;
  1735. }
  1736. q=q->next;
  1737. }
  1738.  
  1739.  
  1740. for(i=0; i<cnt; i++)
  1741. {
  1742. p=head;
  1743. while(p!=NULL)
  1744. {
  1745. if(bookIDTEMP[i] == p->book_num)
  1746. {
  1747. strcpy(&bookNAMETEMP[t][0],p->book_name);
  1748. ++t;
  1749. }
  1750.  
  1751. p=p->next;
  1752.  
  1753. }
  1754. }
  1755.  
  1756. i=0;
  1757. t=0;
  1758.  
  1759.  
  1760. while(bookIDTEMP[i] != 0)
  1761. {
  1762. printf("도서번호:%d\n",bookIDTEMP[i]);
  1763. printf("도서명:%s\n",&bookNAMETEMP[t][0]);
  1764. printf("대여일자:%ld\n",borrowdate[i]);
  1765. printf("반납일자:%ld\n",returndate[i]);
  1766. puts("\n");
  1767. i++;
  1768. t++;
  1769. }
  1770.  
  1771.  
  1772. puts("5초뒤에 자동으로 나갑니다");
  1773. Sleep(5000);
  1774.  
  1775. }
Add Comment
Please, Sign In to add comment