include iostream using namespace std struct library string name string

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace std;
struct library {
string name;
string author;
int year;
};
struct shop {
string name;
string author;
int year;
};
int main() {
struct library library_book;
struct shop shop_book;
printf("Enter name of the book:");
cin >> library_book.name;
printf("Enter author of the book:");
cin >> library_book.author;
printf("Enter year of the book:");
cin >> library_book.year;
cout << "Library book" << endl << "Book name: " << library_book.name << endl;
cout << "Book author: " << library_book.author << endl;
cout << "Book year: " << library_book.year << endl;
shop_book.name = library_book.name;
shop_book.author = library_book.author;
shop_book.year = library_book.year;
cout << "Copying from library struct to shop struct... Completed." << endl;
cout << "Shop book" << endl << "Book name: " << shop_book.name << endl;
cout << "Book author: " << shop_book.author << endl;
cout << "Book year: " << shop_book.year << endl;
return 0;
}