I am creating a library Management system. The system is meant write and read from a .dat file. However the system is having problem writing the user input into the dat file. It is meant write the book name, author name and the book barcode on the same line and then when the user enters another book its meant to add it to another line but it just overwrites the existing data and also when I use the option to display all the data it displays the muddled up text.
#include <string>
#include "Book.h"
#include "Student.h"
void Book::newBook()
{
std::cout<<"Enter the Book Name: \n";
getline(std::cin,name);
std::cin.ignore();
std::cout<<"Enter the Name of Author: \n";
getline(std::cin,author);
std::cin.ignore();
std::cout<<"Enter the book barcode: \n";
getline(std::cin,barcode);
std::cin.ignore();
std::cout<<"Book Added to the library\n";
}
void Book::report()
{
std::cout<<"______________"<<" __________________"<<" _________________\n";
std::cout<<"|Name of Book| "<<"|Director of Book| "<<"|Barcode of Book| \n";
std::cout<<name<<author<<barcode<<"\n";
}