Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <windows.h>
- typedef struct client{
- int ID;
- char PW[100],NAME[100],ADDRESS[100],PNUM[100];
- struct client* next;
- }client;
- typedef struct book
- {
- int book_num;
- char book_name[50];
- char publisher[50];
- char author[20];
- long long ISBN;
- char book_address[50];
- char Y_N[2];
- struct book *next;
- }book;
- typedef struct Borrow
- {
- int stu_num;
- int book_num;
- time_t b_date;
- time_t r_date;
- struct Borrow *next;
- } borrow;
- int temp1;
- int IDD;
- /////////register/////////
- client* create_linkedlist_client(int n);
- int line_of_file(char* name);
- void download_linkedlist_client(client* head);
- void duplicate_inspection_client(client* head);
- void sort_linkedlist_client(client* head);
- void upload_linkedlist_client(client* head);
- void change_my_info(client* head,int n);
- void withdrawal(client* head,int n);
- //////////login///////////
- int login(client* head,int id,char* pw);
- client* create_linkedlist_client_login(int n);
- ////////book///////////
- book* create_linkedlist_book(int n);
- void download_linkedlist_book(book* head);
- void duplicate_inspection_book(book* head);
- void sort_linkedlist_book(book* head);
- void upload_linkedlist_book(book* head);
- void search_linkedlist_book_ISBN(book* head);
- void search_linkedlist_book_bookname(book* head);
- void search_linkedlist_book_publisher(book* head);
- void search_linkedlist_book_author(book* head);
- void search_linkedlist_book_all(book* head);
- ////////////////////////////////////////
- void Register_linkedlist_book(int booknum,book* head);
- int Readbookname_linkedlist_book(book* head,int length);
- void delete_linkedlist_book(book* head);
- client* create_NOINPUT_linkedlist_client(int n);
- client* search_by_clientname(client* head);
- client* search_by_ID(client* head);
- client* Print_all_client(client* head);
- /////////////////////////////////////////////////
- int identifier=0;
- // main start
- int main()
- {
- client* HEAD=NULL;
- client* CLIENT=NULL;
- book* head=NULL;
- int servicestart;
- while(1)
- {
- system("clear");
- puts(">>Library Service<<\n1.Register 2.Login 3.Exit Program");
- scanf("%d",&servicestart);
- switch(servicestart)
- {
- case 1:
- {
- identifier=0;
- system("clear");
- puts("You selected Register");
- puts("Enter Student ID | Password | Name | Address | Phonenumber");
- puts("ex)20180345|ssu2018|DanielHong|KEPCO,Gaepo-dong,Gangnam-gu,seoul|01031414473");
- printf("\n\n");
- HEAD=create_linkedlist_client(line_of_file("client.txt")+1); //Create , INPUT VALUES.
- download_linkedlist_client(HEAD);
- duplicate_inspection_client(HEAD);
- if(identifier==0)
- {
- sort_linkedlist_client(HEAD);
- upload_linkedlist_client(HEAD);
- }
- break;
- }
- case 2:
- {
- int IDD;
- int login_identifier;
- char PW[100];
- int admin_identifier_int;
- char admin_identifier_string[10];
- int break_or_admin=0;
- while(1)
- {
- system("clear");
- puts(">>Login<<");
- fputs("ID:",stdout);
- admin_identifier_int=scanf("%d",&IDD);
- if (admin_identifier_int != 1) //string
- {
- system("clear");
- puts("Did you entered string?");
- puts("If you enter admin , connected with administrator authority");
- puts("If you enter other string , goes back to main menu");
- while(getchar() !='\n'); //clean input buffer,beacuse of scanf error.
- scanf("%s",admin_identifier_string);
- if(strcmp(admin_identifier_string,"admin")==0)
- {
- break_or_admin=1;
- break;
- }
- else
- {
- break_or_admin=0;
- break;
- }
- }
- fputs("PW:",stdout);
- scanf("%s",PW);
- HEAD=create_linkedlist_client_login(line_of_file("client.txt"));
- download_linkedlist_client(HEAD);
- login_identifier=login(HEAD,IDD,PW);
- if(login_identifier==0) //Wrong
- {
- system("clear");
- puts("Wrong ID or PW");
- puts("Try again in 3sec");
- Sleep(3000);
- }
- if(login_identifier==1) //Pass
- break;
- }
- if(login_identifier==1 && break_or_admin!=1)
- {
- while(1)
- {
- head=create_linkedlist_book(line_of_file("book.txt"));
- download_linkedlist_book(head);
- system("clear");
- int input=0;
- puts(">>>MENU<<<");
- puts("1.Search book 2.My borrow list 3.Edit personal information");
- puts("4.Membership withdrawal 5.Logout 6.Exit program");
- scanf("%d",&input);
- switch(input)
- {
- case 1:
- {
- int menuselect=0;
- system("clear");
- puts("1.Search with book name 2.Search with publisher 3.Search with ISBN");
- puts("4.Search with author 5.search all 6.previous menu");
- scanf("%d",&menuselect);
- switch(menuselect)
- {
- case 1:
- {
- search_linkedlist_book_bookname(head);
- break;
- }
- case 2:
- {
- search_linkedlist_book_publisher(head);
- break;
- }
- case 3:
- {
- search_linkedlist_book_ISBN(head);
- break;
- }
- case 4:
- {
- search_linkedlist_book_author(head);
- break;
- }
- case 5:
- {
- search_linkedlist_book_all(head);
- break;
- }
- case 6:
- {
- break;
- }
- }
- break;
- }
- case 2:
- {
- break;
- }
- case 3:
- {
- HEAD=create_linkedlist_client_login(line_of_file("client.txt"));
- download_linkedlist_client(HEAD);
- sort_linkedlist_client(HEAD);
- change_my_info(HEAD,IDD);
- }
- case 4:
- {
- HEAD=create_linkedlist_client_login(line_of_file("client.txt"));
- download_linkedlist_client(HEAD);
- sort_linkedlist_client(HEAD);
- withdrawal(HEAD,IDD);
- }
- case 5:
- {
- break;
- }
- case 6:
- {
- return 0;
- }
- }
- if(input==5)
- break;
- } //while
- } //if
- if(break_or_admin==1)
- {
- while(1)
- {
- int foradmin=0;
- system("clear");
- puts("1.Register book 2.Delete book 3.Borrow book");
- puts("4.Return book 5.Search book 6.Member list");
- puts("7.Logout 8.Exit program");
- int booknum;
- scanf("%d",&foradmin);
- switch(foradmin)
- {
- case 1:
- {
- head=create_linkedlist_book(line_of_file("book.txt"));
- download_linkedlist_book(head);
- sort_linkedlist_book(head);
- //upload_linkedlist_book(head);
- booknum=Readbookname_linkedlist_book(head,line_of_file("book.txt"));
- Register_linkedlist_book(booknum,head);
- head=create_linkedlist_book(line_of_file("book.txt"));
- download_linkedlist_book(head);
- sort_linkedlist_book(head);
- upload_linkedlist_book(head);
- break;
- }
- case 2:
- {
- head=create_linkedlist_book(line_of_file("book.txt"));
- download_linkedlist_book(head);
- sort_linkedlist_book(head);
- delete_linkedlist_book(head);
- break;
- }
- case 3:
- {
- break;
- }
- case 4:
- {
- break;
- }
- case 5:
- {
- int menuselect=0;
- system("clear");
- puts("1.Search with book name 2.Search with publisher 3.Search with ISBN");
- puts("4.Search with author 5.search all 6.previous menu");
- scanf("%d",&menuselect);
- switch(menuselect)
- {
- case 1:
- {
- search_linkedlist_book_bookname(head);
- break;
- }
- case 2:
- {
- search_linkedlist_book_publisher(head);
- break;
- }
- case 3:
- {
- search_linkedlist_book_ISBN(head);
- break;
- }
- case 4:
- {
- search_linkedlist_book_author(head);
- break;
- }
- case 5:
- {
- search_linkedlist_book_all(head);
- break;
- }
- case 6:
- {
- break;
- }
- }
- break;
- }
- case 6:
- {
- int forclient=0;
- system("clear");
- puts(">>>>>>>>>LIST OF CLIENTS<<<<<<<<<<");
- puts("1.Search with name 2.Search with ID");
- puts("3.Print all 4.Previous menu");
- scanf("%d",&forclient);
- if(forclient==1)
- {
- CLIENT=create_NOINPUT_linkedlist_client(line_of_file("client.txt")); //Create , INPUT VALUES.
- download_linkedlist_client(CLIENT);
- sort_linkedlist_client(CLIENT);
- upload_linkedlist_client(CLIENT);
- search_by_clientname(CLIENT);
- }
- if(forclient==2)
- {
- CLIENT=create_NOINPUT_linkedlist_client(line_of_file("client.txt")); //Create , INPUT VALUES.
- download_linkedlist_client(CLIENT);
- sort_linkedlist_client(CLIENT);
- upload_linkedlist_client(CLIENT);
- search_by_ID(CLIENT);
- }
- if(forclient==3)
- {
- CLIENT=create_NOINPUT_linkedlist_client(line_of_file("client.txt")); //Create , INPUT VALUES.
- download_linkedlist_client(CLIENT);
- sort_linkedlist_client(CLIENT);
- upload_linkedlist_client(CLIENT);
- Print_all_client(CLIENT);
- }
- if(forclient==4)
- {
- break;
- }
- break;
- }
- case 7:
- {
- break;
- }
- case 8:
- {
- return 0;
- }
- }
- if(foradmin==7)
- break;
- }//while
- } //if
- break;
- }//case2
- case 3:
- break;
- }//switch
- }//while
- return 0;
- }//main
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- client* create_linkedlist_client(int n)
- {
- client* head=NULL;
- client* temp=NULL;
- client* p = NULL;
- char temp2[100],temp3[100],temp4[100],temp5[100];
- int i;
- scanf("%d|%[^|]|%[^|]|%[^|]|%s",&temp1,temp2,temp3,temp4,temp5);
- for(i=0;i<n;i++)
- {
- temp =(client*)malloc(sizeof(client));
- temp->ID=temp1; strcpy(temp->PW,temp2); strcpy(temp->NAME,temp3);
- strcpy(temp->ADDRESS,temp4); strcpy(temp->PNUM,temp5);
- temp->next=NULL;
- if(head==NULL)
- {
- head=temp;
- }
- else
- {
- p=head;
- while(p->next != NULL)
- p=p->next;
- p->next = temp;
- }
- }
- return head;
- }
- void upload_linkedlist_client(client* head)
- {
- client* p=head;
- FILE *f=fopen("client.txt","w");
- while(p !=NULL)
- {
- fprintf(f,"%d|%s|%s|%s|%s\n",p->ID,p->PW,p->NAME,p->ADDRESS,p->PNUM);
- p = p->next;
- }
- fclose(f);
- }
- void download_linkedlist_client(client* head)
- {
- client* p=head;
- FILE *f=fopen("client.txt","r");
- while(p !=NULL)
- {
- fscanf(f,"%d|%[^|]|%[^|]|%[^|]|%s\n",&(p->ID),p->PW,p->NAME,p->ADDRESS,p->PNUM);
- p = p->next;
- }
- fclose(f);
- }
- void sort_linkedlist_client(client* head)
- {
- client *i,*j;
- int temp1;
- char temp2[100],temp3[100],temp4[100],temp5[100];
- for(i=head;i->next!=NULL;i=i->next)
- {
- for(j=i->next; j!=NULL; j=j->next)
- {
- if(i->ID > j->ID)
- {
- temp1 = i->ID;
- strcpy(temp2,i->PW); strcpy(temp3,i->NAME); strcpy(temp4,i->ADDRESS); strcpy(temp5,i->PNUM);
- i->ID=j->ID;
- strcpy(i->PW,j->PW); strcpy(i->NAME,j->NAME); strcpy(i->ADDRESS,j->ADDRESS); strcpy(i->PNUM,j->PNUM);
- j->ID=temp1; strcpy(j->PW,temp2); strcpy(j->NAME,temp3); strcpy(j->ADDRESS,temp4); strcpy(j->PNUM,temp5);
- }
- }
- }
- }
- int line_of_file(char * name)
- {
- FILE *fp;
- char buf[1024];
- int i;
- fp=fopen(name ,"r");
- for (i=0,buf[1022]=0; fgets(buf,1024,fp); buf[1022]=0)
- (buf[1022] && buf[1022] != '\n') ? : i++;
- fclose(fp);
- return i;
- }
- void duplicate_inspection_client(client* head)
- {
- client* p=head;
- while(p->next!=NULL)
- {
- if(temp1 == p->ID)
- {
- system("clear");
- puts("ERROR!! Have a Same ID");
- puts("Going back to main menu in 5sec...");
- identifier=1;
- Sleep(5000);
- break;
- }
- p = p->next;
- }
- }
- int login(client* head,int id,char* pw)
- {
- client* p=head;
- while(p != NULL)
- {
- if((id == p->ID)==1 && strcmp(pw,p->PW)==0)
- return 1;
- p = p->next;
- }
- return 0;
- }
- client* create_linkedlist_client_login(int n)
- {
- int i;
- client* head=NULL;
- client* temp=NULL;
- client* p = NULL;
- for(i=0;i<n;i++)
- {
- temp =(client*)malloc(sizeof(client));
- temp->next=NULL;
- if(head==NULL)
- {
- head=temp;
- }
- else
- {
- p=head;
- while(p->next != NULL)
- p=p->next;
- p->next = temp;
- }
- }
- return head;
- }
- void change_my_info(client* head,int n)
- {
- client* p=head;
- char tempPW[100],tempADDRESS[100],tempPNUM[100];
- system("clear");
- puts("Enter new PW");
- while(getchar()!='\n');
- scanf("%[^\n]",tempPW);
- puts("Enter new ADDRESS");
- while(getchar()!='\n');
- scanf("%[^\n]",tempADDRESS);
- puts("Enter new PNUM");
- while(getchar()!='\n');
- scanf("%[^\n]",tempPNUM);
- FILE* f=fopen("client.txt","w");
- while(p!=NULL)
- {
- if(n==p->ID)
- fprintf(f,"%d|%s|%s|%s|%s\n",p->ID,tempPW,p->NAME,tempADDRESS,tempPNUM);
- if(n!=p->ID)
- fprintf(f,"%d|%s|%s|%s|%s\n",p->ID,p->PW,p->NAME,p->ADDRESS,p->PNUM);
- p=p->next;
- }
- fclose(f);
- }
- void withdrawal(client* head,int n)
- {
- int repeat_value=1;
- client* p=head;
- while(1)
- {
- if(p->ID==n)
- {
- printf("%d|%s|%s|%s|%s\n",p->ID,p->PW,p->NAME,p->ADDRESS,p->PNUM);
- puts("Delete in 5sec");
- Sleep(5000);
- p=head;
- FILE* f=fopen("client.txt","w");
- int i=1;
- while(p!=NULL)
- {
- if(i!=repeat_value)
- fprintf(f,"%d|%s|%s|%s|%s\n",p->ID,p->PW,p->NAME,p->ADDRESS,p->PNUM);
- ++i;
- p=p->next;
- }
- fclose(f);
- break;
- }
- repeat_value++;
- p=p->next;
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////
- void search_linkedlist_book_ISBN(book* head)
- {
- long long tempforISBN;
- int ISBN_identifier=0;
- system("clear");
- book* p=head;
- puts("Enter ISBN");
- scanf("%lld",&tempforISBN);
- system("clear");
- while(p != NULL)
- {
- if(tempforISBN == p->ISBN)
- {
- 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);
- ISBN_identifier=1;
- }
- p = p->next;
- }
- if(ISBN_identifier==0)
- {
- system("clear");
- puts("Wrong! Going back to menu in 3sec");
- Sleep(3000);
- }
- if(ISBN_identifier==1)
- {
- puts("Going back to menu in 5sec");
- Sleep(5000);
- }
- }
- void search_linkedlist_book_bookname(book* head)
- {
- char tempforbookname[50];
- int bookname_identifier=0;
- system("clear");
- book* p=head;
- puts("Enter bookname");
- while(getchar()!='\n');
- scanf("%[^\n]",tempforbookname);
- system("clear");
- while(p != NULL)
- {
- if(strcmp(tempforbookname,p->book_name)==0)
- {
- 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);
- bookname_identifier=1;
- }
- p = p->next;
- }
- if(bookname_identifier==0)
- {
- system("clear");
- puts("Wrong! Going back to menu in 3sec");
- Sleep(3000);
- }
- if(bookname_identifier==1)
- {
- puts("Going back to menu in 5sec");
- Sleep(5000);
- }
- }
- void search_linkedlist_book_publisher(book* head)
- {
- char temp_book_publisher[50];
- int bookpublisher_identifier=0;
- system("clear");
- book* p=head;
- puts("Enter publisher");
- while(getchar()!='\n');
- scanf("%[^\n]",temp_book_publisher);
- system("clear");
- while(p != NULL)
- {
- if(strcmp(temp_book_publisher,p->publisher)==0)
- {
- 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);
- bookpublisher_identifier=1;
- }
- p = p->next;
- }
- if(bookpublisher_identifier==0)
- {
- system("clear");
- puts("Wrong! Going back to menu in 3sec");
- Sleep(3000);
- }
- if(bookpublisher_identifier==1)
- {
- puts("Going back to menu in 5sec");
- Sleep(5000);
- }
- }
- void search_linkedlist_book_author(book* head)
- {
- char tempforbookauthor[50];
- int bookauthor_identifier=0;
- system("clear");
- book* p=head;
- puts("Enter bookname");
- while(getchar()!='\n');
- scanf("%[^\n]",tempforbookauthor);
- system("clear");
- while(p != NULL)
- {
- if(strcmp(tempforbookauthor,p->author)==0)
- {
- 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);
- bookauthor_identifier=1;
- }
- p = p->next;
- }
- if(bookauthor_identifier==0)
- {
- system("clear");
- puts("Wrong! Going back to menu in 3sec");
- Sleep(3000);
- }
- if(bookauthor_identifier==1)
- {
- puts("Going back to menu in 5sec");
- Sleep(5000);
- }
- }
- void search_linkedlist_book_all(book* head)
- {
- system("clear");
- book* p=head;
- while(p != NULL)
- {
- 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);
- p = p->next;
- }
- puts("Going back to menu in 5sec");
- Sleep(5000);
- }
- book* create_linkedlist_book(int n)
- {
- book* head=NULL;
- book* temp=NULL;
- book* p = NULL;
- int i;
- for(i=0;i<n;i++)
- {
- temp =(book*)malloc(sizeof(book));
- temp->next=NULL;
- if(head==NULL)
- {
- head=temp;
- }
- else
- {
- p=head;
- while(p->next != NULL)
- p=p->next;
- p->next = temp;
- }
- }
- return head;
- }
- void download_linkedlist_book(book* head)
- {
- book* p=head;
- FILE *f=fopen("book.txt","r");
- while(p !=NULL)
- {
- fscanf(f,"%d|%[^|]|%[^|]|%[^|]|%lld|%[^|]|%s\n",&(p->book_num),p->book_name,p->publisher,p->author,&(p->ISBN),p->book_address,p->Y_N);
- p = p->next;
- }
- fclose(f);
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void sort_linkedlist_book(book* head)
- {
- book *i,*j;
- int temp1;
- long long temp5;
- char temp2[100],temp3[100],temp4[100],temp6[100],temp7[2];
- for(i=head;i->next!=NULL;i=i->next)
- {
- for(j=i->next; j!=NULL; j=j->next)
- {
- if(i->ISBN > j->ISBN)
- {
- temp1 = i->book_num; temp5 = i->ISBN;
- strcpy(temp2,i->book_name); strcpy(temp3,i->publisher); strcpy(temp4,i->author); strcpy(temp6,i->book_address); strcpy(temp7,i->Y_N);
- i->book_num = j->book_num; i->ISBN = j->ISBN;
- 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);
- j->book_num = temp1; j->ISBN = temp5;
- strcpy(j->book_name,temp2); strcpy(j->publisher,temp3); strcpy(j->author,temp4); strcpy(j->book_address,temp6); strcpy(j->Y_N,temp7);
- }
- }
- }
- }
- void upload_linkedlist_book(book* head)
- {
- book* p=head;
- FILE *f=fopen("book.txt","w");
- while(p !=NULL)
- {
- 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);
- p = p->next;
- }
- fclose(f);
- }
- void Register_linkedlist_book(int booknum,book* head)
- {
- book* p=head;
- FILE *f=fopen("book.txt","a");
- char temp1[100],temp2[100],temp3[100],temp5[100];
- long long temp4;
- puts("Book name:");
- getchar();
- scanf("%[^\n]",temp1);
- puts("Publisher:");
- getchar();
- scanf("%[^\n]",temp2);
- puts("Author:");
- getchar();
- scanf("%[^\n]",temp3);
- puts("ISBN:");
- scanf("%lld",&temp4);
- puts("Book adrress:");
- getchar();
- scanf("%[^\n]",temp5);
- fprintf(f,"%d|%s|%s|%s|%ld|%s|Y\n",booknum+1,temp1,temp2,temp3,temp4,temp5);
- fclose(f);
- }
- int Readbookname_linkedlist_book(book* head,int length)
- {
- book* p=head;
- for(int i=0;i<length;i++)
- {
- if(i==length-1)
- {
- return p->book_num;
- }
- p=p->next;
- }
- return 0;
- }
- void delete_linkedlist_book(book* head)
- {
- int menuselect;
- long long tempISBN;
- char tempbookname[100];
- int repeat_value=1;
- book* p=head;
- puts("1.Delete by book name");
- puts("2.Delete by ISBN");
- scanf("%d",&menuselect);
- if(menuselect==1)
- {
- puts("Enter book name");
- while(getchar() != '\n');
- scanf("%[^\n]",tempbookname);
- while(1)
- {
- if(strcmp(p->book_name,tempbookname)==0)
- {
- if(strcmp(p->Y_N,"N")==0)
- {
- puts("YOU CAN`T BORROW THIS BOOK");
- puts("Turn back to menu in 5sec..");
- Sleep(5000);
- break;
- }
- 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);
- puts("Delete in 5sec");
- Sleep(5000);
- p=head;
- FILE* f=fopen("book.txt","w");
- int i=1;
- while(p!=NULL)
- {
- if(i!=repeat_value)
- 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);
- ++i;
- p=p->next;
- }
- fclose(f);
- break;
- }
- repeat_value++;
- p=p->next;
- }
- }
- if(menuselect==2)
- {
- puts("Enter ISBN");
- scanf("%lld",&tempISBN);
- while(1)
- {
- if(p->ISBN==tempISBN)
- {
- if(strcmp(p->Y_N,"N")==0)
- {
- puts("YOU CAN`T BORROW THIS BOOK");
- puts("Turn back to menu in 5sec..");
- Sleep(5000);
- break;
- }
- 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);
- puts("Delete in 5sec");
- Sleep(5000);
- p=head;
- FILE* f=fopen("book.txt","w");
- int i=1;
- while(p!=NULL)
- {
- if(i!=repeat_value)
- 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);
- ++i;
- p=p->next;
- }
- fclose(f);
- break;
- }
- repeat_value++;
- p=p->next;
- }
- }
- }
- client* create_NOINPUT_linkedlist_client(int n)
- {
- client* head=NULL;
- client* temp=NULL;
- client* p = NULL;
- int i;
- for(i=0;i<n;i++)
- {
- temp =(client*)malloc(sizeof(client));
- temp->next=NULL;
- if(head==NULL)
- {
- head=temp;
- }
- else
- {
- p=head;
- while(p->next != NULL)
- p=p->next;
- p->next = temp;
- }
- }
- return head;
- }
- client* search_by_clientname(client* head)
- {
- system("clear");
- char temp_clientname[100];
- puts("Enter client name");
- while(getchar()!='\n');
- scanf("%[^\n]",temp_clientname);
- client* p=head;
- while(p!=NULL)
- {
- if(strcmp(p->NAME,temp_clientname)==0)
- {
- printf("%d|%s|%s|%s\n",p->ID,p->NAME,p->ADDRESS,p->PNUM);
- }
- p=p->next;
- }
- puts("Going back to previous menu in 5sec...");
- Sleep(5000);
- }
- client* search_by_ID(client* head)
- {
- system("clear");
- int temp_clientID;
- puts("Enter client ID");
- scanf("%d",&temp_clientID);
- client* p=head;
- while(p!=NULL)
- {
- if(p->ID==temp_clientID)
- {
- printf("%d|%s|%s|%s\n",p->ID,p->NAME,p->ADDRESS,p->PNUM);
- }
- p=p->next;
- }
- puts("Going back to previous menu in 5sec...");
- Sleep(5000);
- }
- client* Print_all_client(client* head)
- {
- system("clear");
- puts(">>PRINT ALL<<");
- client* p=head;
- while(p!=NULL)
- {
- printf("%d|%s|%s|%s\n",p->ID,p->NAME,p->ADDRESS,p->PNUM);
- p=p->next;
- }
- puts("Going back to previous menu in 5sec...");
- Sleep(5000);
- }
Add Comment
Please, Sign In to add comment