C++

C++ Project on Library Management

Library Management System

#include
#include
#include
#include
#include
#include
#include
#include
#include

class lib
{
public:
    char name[20];
    int clas, rollno;

    void get()
    {
        cout << "******* enter the details of the student:" << endl;
        cout << "enter the class:";
        cin >> clas;
        cout << "enter the rollno:";
        cin >> rollno;
    }

    void show()
    {
        cout << "******** DETAILS ADDED ARE ***********:" << endl;
    }
};

int x;
switch(x)
{
    case 1:
    {
        char ch = 'y';
        lib s;
        fstream t;
        t.open("navi.txt", ios::binary | ios::out | ios::app | ios::in);
        while (ch == 'y' || ch == 'Y')
        {
            s.get();
            t.write((char*)&s, sizeof(lib));
            cout << "do you want to add more(y/n)....:";
            cin >> ch;
        }
    }

    case 2:
    {
        lib s;
        fstream t;
        t.open("navi.txt", ios::binary | ios::out | ios::app | ios::in);
        t.seekg(0);
        while (t.read((char*)&s, sizeof(lib)))
        {
            s.show();
        }
    }
    break;

    case 3:
    {
        int a[20];
        lib s;
        fstream t;
        t.open("navi.txt", ios::binary | ios::out, ios::app | ios::in);
        t.seekg(0);
        cout << "enter the name you want to search:";
        cin >> a[i];
        while (t.read((char*)&s, sizeof(lib)))
        {
            s.show();
        }
        cout << "name not found:";
    }
}
Share:

Comments from readers

Leave a Comment

Share your thoughts below. Comments appear after a quick review.

You may also want to see: