Link to home
Start Free TrialLog in
Avatar of Dinesh Kumar
Dinesh KumarFlag for India

asked on

c++ file handling a simple library information system

can you provide me a simple program in c++ providing insert,update,delete and show the books?
the records should be kept in a file on the disk.
Avatar of Infinity08
Infinity08
Flag of Belgium image

Insert into what ? Update what ? Delete what ?

Are you talking about interaction with a database ? Which database ?
Hi,

   If i understand your question correctly, you can use linked lists to create a database dynamically and store database of what you have entered and retrieve the same,
  You need to go through what are linked lists , refer a good book about linked lists
 the following links can help to learn the basics,
c++:
-----
http://www.functionx.com/cpp/articles/linkedlist.htm
http://www.cplusplus.com/doc/tutorial/files/
c:
---
http://www.cprogramming.com/tutorial/lesson15.html
http://www.codeproject.com/KB/cpp/linked_list.aspx

  Create a linked list structre which all the datas you have mentioned,
struct libraryDB
{
  int bookNum;
 char *authName;
 etc..
 struct libraryDB *nextlibraryDB; //link to the structure
}

add function to add,delete ,insert,sort the linked lists

 try that all mentioned and comeback if you have issue ,we experts are here to help you
Avatar of Dinesh Kumar

ASKER

I want to keeps books' information like title, price, accession number in a file. so i need to use the file handling in c++. suppose I need to update the title of the book then i will open the file through c++ code in write only mode and will go to that specific records by using some id say accession number and update that particular book information.
Is this for professional purposes, a personal project, an academic assignment ?

Depending on what this is for, the answer will be very different. So a bit more background information would be useful.

How many books do you want to store ? And how do you want to access that information ? Is the access local only, or do you need access from different locations ? What kind of access do you need precisely ? Etc.
its for academic assignment.  every book will be having its own unique id. it will be used on a single system.
ASKER CERTIFIED SOLUTION
Avatar of masheik
masheik
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Masheik, I am working on following. Actually i just  noticed that I need to use inheritance concept.

How can i use inheritance in following problem?


Make a menu-driven project to create a library information system containing the following information for the proper storage and processing of books in the library.
(a) Accession Number                  (b) Name of the Author
(c) Title of the Book                  (d) Publisher Name
(e) Publisher Name                  (f) Cost of the Book
(g) Year of Publication            (h) Number of pages
Use the of inheritance

Menus:
1) Add a new Book
2) Display all the books
3) Delete a Book Details (Soft Delete only)
4) Search a book using Accession Number

the code i attached is to be still modified.
Article583-2792010.zip
>> its for academic assignment.  every book will be having its own unique id. it will be used on a single system.

I would start by implementing the "Add a new Book" feature. You'd need a Book class that represents a book. Its data members should describe all specifics of the book (title, author, year, etc.). And it should have some methods for manipulating the book (nothing special probably - just provide ways of retrieving and modifying the data members).

You can then write some code that asks the user to enter the details for a new book. While the details are being entered, you set them in a new instance of the Book class (via its constructor possibly). Once the Book instance has been filled, you can write some code that writes the information for the book to a file (or : that serializes a Book instance to a file).

When you have that, you can write code that retrieves a book from the file, creates a new Book instance for it, and keeps it in memory, where it can be manipulated.

The next step would be to have an in-memory data structure that can hold many Book instances, and provides a convenient way for performing lookup. Which data structure you choose will probably depend on what data structures you have already worked with during your classes.

You can then adapt your code to read multiple books from a file, and store them in the data structure. And to be able to write all books from the data structure back to a file.

All that is left after this is done, is some small features, which you can then add one by one.


Since your original question was about file handling in C++, I recommend that you have a look at this tutorial to guide you :

        http://www.cplusplus.com/doc/tutorial/files/
and how can we use the concept of inheritance?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did not find the complete solution.
>> I did not find the complete solution.

Then why didn't you ask us for clarification about the parts that haven't been addressed ? Why didn't you respond to our last posts ?