Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdlib.h>
- #include<string.h>
- #include<iostream>
- #include<fstream>
- using namespace std;
- const size_t MAX_LEN = 256;
- struct book {
- char author[MAX_LEN];
- char name[MAX_LEN];
- int edition;
- int price;
- };
- void read(book &b, istream &is){
- is >> b.author >> b.name >> b.edition >> b.price;
- }
- void write(const book &b, ostream &os){
- os << b.author << " "
- << b.name << " "
- << b.edition << " "
- << b.price << "\n";
- }
- int main(){
- ifstream in("input.txt");
- int n;
- in >> n;
- book *lib = new book[n];
- for (int i = 0; i < n; ++i){
- read(lib[i], in);
- }
- cout << "Library (input.txt): \n";
- for (int i = 0; i < n; ++i){
- write(lib[i], cout);
- }
- delete[] lib;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement