В фаил выводится то, что вводится +ещё какие то символы?
+пока ещё не понятно, насколько праивльно я это всё сделал.
Буду рад любому комментарию..
#include "books.h"
#include "global.h"
#include "menu.h"
#include "readers.h"
#include <sstream>
#include <vector>
#include <algorithm>
#include <iterator>
vector<structBook> vecStructBook;
int bookCount=0;
structBook book;
vector<structBook>::iterator iterBook;
void addBook(void)
{
ofstream bookDatabase;
bookDatabase.open("bookDatabaseFile.txt", ios::app);
if (!bookDatabase)
cout << "File open error" << endl;
else
{
cout << "Please enter information about book" << endl;
cout << "How much book you want to enter" << endl;
int bookNumberForEnter;
cin >> bookNumberForEnter;
for (int i=0; i< bookNumberForEnter;i++)
{
cout << "Book id: " << endl;
cin >> book.bookId;
cout << "Please enter book name: ";
cin >> book.bookName;
cout << "Please enter book author name: ";
cin >> book.bookAuthorName;
cout << "Please enter book author surname: ";
cin >> book.bookAuthorSurname;
cout << "Please enter publising house name: ";
cin >> book.publishingHouse;
cout << "Please enter book publishing year: ";
cin >> book.year;
cout << "Please enter book pages amount:";
cin >> book.pages;
cout << "Please enter is book on place:";
cin >> book.onplace;
cout << "Please enter book genre:";
cin >> book.genre;
cout << "Please enter book section:";
cin >> book.section;
bookCount++;
vecStructBook.push_back(book);
for (iterBook = vecStructBook.begin(); iterBook < vecStructBook.end(); iterBook++)
{
bookDatabase.write(reinterpret_cast<char*>(&book), sizeof(structBook));
cout << "Book added" << endl;
}
}
bookDatabase.close();
}
}