#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    6
    Rep Power
    0

    Exclamation Help with my project !!!!


    My project is about Library system management
    I need some help with it
    any one can tell me what should i do to get on it?!
    Thanks,,
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    236
    Rep Power
    28
    Obviously you should start from collecting your brain into one heap and writing some more thorough and clear description of your task, divided by actions, paragraphs etc.

    Then you should start some coding.

    Then if you feel some stuck - get here with informative message about your problem.
    CodeAbbey - programming problems for novice coders
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    6
    Rep Power
    0
    Thank you for helping,
    I started on the project and i have some problems until now like:
    -- when i ask user to enter 1 to add more books or 2 to return to menu the problem lies when user enters any other input. I made switch statement for it and the default prints "wrong choice" but i can't make program ask him again to enter input.
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    We are not clairvoyent, not can we astral travel to look over your shoulder at your code. And we cannot read your mind.

    We need to actually see the code to be able to know what it says and does. You need to post the code. Format it properly by indenting it -- a very good and readable indent style is Allman style -- K&R style is very problematic in that it depends absolutely on a consistent indenting style. Use code tags to preserve the indentation! HTML will strip out those leading spaces, so you absolutely must use code tags:

    [code] {insert your formatted code here} [/code]
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    You'll need a loop and also to know that most switch statements include a lot of break; statements.
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    6
    Rep Power
    0
    My code is ::
    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<stdlib.h>
    #include<string.h>
    #include <windows.h>
    #include<stdio.h>                   //contains printf,scanf etc
    #include<conio.h>                   //contains delay(),getch(),gotoxy(),etc.
    #include <stdlib.h>
    #include<string.h>                  //contains strcmp(),strcpy(),strlen(),etc
    #include<dos.h>                     //contains _dos_getdate
    #include<time.h>
    
    void bookmang();
    void addcopies();
    void mainmenu();
    int ind=0;
    int ind2;
    
    void addbooks();
    
    
    void delay(unsigned int mseconds)               /* or using nested loop with 32767 in the 2 loops */
    {
        clock_t goal = mseconds + clock();
        while (goal > clock());
    }
    
    
    struct books
        {
            char title[100];
            char author[100];
            char publisher[100];
            char ISBN[100];
            char dateofpublication[100];
            int numberofcopies;
            int currentavailablenumofcopies;
            char category[100];
        };
        struct books book[1000];
    
        struct members
        {
            int ID;
            char name[100];
            char address[100];
            char street[100];
            char city[100];
            int phonenumber;
            int age;
            char email[100];
        };
        struct members member[1000];
    int main()
    {
        printf("\n \n \n \t \t Welcome to library system management \n");
        printf("\n \n \n \t \t Press any key to continue ..... ");
        getch();
        mainmenu();
        return 0;
    }
    void mainmenu()
    {
    
            int n,a;
    
            system("cls");
            printf("Choose one of these choices : \n\n");
            printf("1- Book managment \n\n");
            printf("2- Member managment \n\n");
            printf("3- Adminstrative actions \n\n");
            printf("4- Quit the program \n\n");
            switch(getch()){
                case'1':
                    bookmang();
                    break;
                case'2':
                    break;
                case'3':
                    break;
                case'4':
                    system("cls");
                    printf("Thank You !\n");
                    printf("Program will stop in\n3 seconds \n");
                    delay(1000);
                    printf("2 seconds \n");
                    delay(1000);
                    printf("1 seconds \n");
                    delay(1000);
                    exit(0);
                    break;
                default:
                    printf("wrong choice !");
                    delay(500);
                    mainmenu();
            }
    }
    
    
    void bookmang()
    {
    
        system("cls");
        printf("1- Add books \n\n");
        printf("2- Search for a book \n\n");
        printf("3- Add new copies \n\n");
        printf("4- Delete book \n\n");
        printf("5- Back to mainmenu \n\n");
        printf("choose the operation \n\n");
    
        switch(getch()){
            case'1':
                addbooks();
                break;
            case'2':
                break;
            case'3':
                addcopies();
                break;
            case'4':
                break;
            case'5':
                mainmenu();
                break;
            default:
                printf("wrong choice !");
                delay(500);
                bookmang();
        }
    }
    
    
    void addbooks()
    {
        system("cls");
            FILE * addb;
            addb=fopen ("addbooks.txt","a");
            printf("book title : ");
            gets(book[ind].title);
            printf("book author : ");
            gets(book[ind].author);
            printf("book publisher : ");
            gets(book[ind].publisher);
            printf("book ISBN : ");
            gets(book[ind].ISBN);
            printf("book dateofpublication : ");
            gets(book[ind].dateofpublication);
            printf("book numberofcopies : ");
            scanf("%d",&book[ind].numberofcopies);
            getchar();
            book[ind].currentavailablenumofcopies=book[ind].numberofcopies;
            printf("book category : ");
            gets(book[ind].category);
            fprintf(addb,"- %s,%s,%s,%s,%s,%d,%d,%s\n",book[ind].title,book[ind].author,book[ind].publisher,book[ind].ISBN,book[ind].dateofpublication,book[ind].numberofcopies,book[ind].currentavailablenumofcopies,book[ind].category);
            fclose(addb);
            ind++;
            int z;
            do{
            printf("Do you want to add more books ?\n");
            printf("Press 1 for Yes\nPress 2 for No\n\n");
            z=getch();
            switch(z){
                case '1':
                    addbooks();
                case '2':
                    mainmenu();
            }
            printf("Wrong input Plz answer the question with reasonable answers 1 or 2");
            delay(2000);
            system("cls");
        }while(z!=1 || z!=2);
    }
    
    void addcopies()
    {
        int a,b;
        int i=0;
        FILE * addb;
        system("cls");
        printf("Enter the ISBN of the book you want to add copies of it \n");
        scanf("%d",&a);
        getchar();
        printf("Enter the number of copies to add \n");
        scanf("%d",&b);
        getchar();
        addb=fopen ("addbooks.txt","a");
        for (i=0 ; i<1000 ; ){
            if (a==book[i].ISBN){
                printf("Found ISBN of book %d\n",i);
                book[i].numberofcopies+=b;
                book[i].currentavailablenumofcopies+=b;
                printf("number of copies is : %d\n", book[i].numberofcopies);
                printf("number of available copies is : %d\n",book[i].currentavailablenumofcopies);
                break;
            }
            else
                i++;
        }
        if (i==1000){
            printf("not found\n");
        }
        fclose(addb);
        int z;
        do{
            printf("Do you want to add copies again ? \n");
            printf("1 for yes\n2 for no\n\n");
            z=getch();
            switch(z){
            case '1':
                addcopies();
            case '2':
                bookmang();
            }
            printf("Wrong input Plz answer the question with reasonable answers 1 or 2");
            delay(2000);
            system("cls");
        }while(z!=1 || z!=2);
    }
    
    void savefile ()
    {
        FILE*addb;
        char booksave[1000],*temp;
        addb=fopen("addbooks.txt","r");
        while(fgets(booksave,1000,addbooks)!=NULL)
        {
            temp=strtok(booksave,",");
            strcpy(book[ind].title,temp);
            temp=strtok(NULL,",");
            strcpy(book[ind].author,temp);
            temp=strtok(NULL,",");
            strcpy(book[ind].publisher,temp);
            temp=strtok(NULL,",");
            strcpy(book[ind].ISBN,temp);
            temp=strtok(NULL,",");
            strcpy(book[ind].dateofpublication,temp);
            temp=strtok(NULL,",");
            book[ind].numberofcopies=atoi(temp);
            temp=strtok(NULL,",");
            book[ind].currentavailablenumofcopies=atoi(temp);
            temp=strtok(NULL,",");
            strcpy(book[ind].category,temp);
            ind++;
    
        }
        ind2=ind;
        for (i=0 ; i<ind2 ; i++)
        {
            
        }
    }


    I need help to complete save file and how to load file
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    73
    Rep Power
    2
    Originally Posted by mizo121
    I need help to complete save file and how to load file
    read File I/O chapter from the book again.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    6
    Rep Power
    0
    Thanks for helping,
    Now i have 2 problems.
    1- i should make user search for book by entering title the problem is that he doesn't have to enter the whole title. He can enter part of it.
    How i handle something like that ?!
    2- user can delete books how i can delete book from the structure above in the code ?!

    And sorry for annoying you.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    73
    Rep Power
    2
    Originally Posted by mizo121
    Thanks for helping,
    Now i have 2 problems.
    1- i should make user search for book by entering title the problem is that he doesn't have to enter the whole title. He can enter part of it.
    How i handle something like that ?!
    2- user can delete books how i can delete book from the structure above in the code ?!

    And sorry for annoying you.
    for problem 1:

    search strings character by character. if enough(you have to set how many) characters are matching then show those book names.

IMN logo majestic logo threadwatch logo seochat tools logo