fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5. void printBook( struct Books book );
  6.  
  7. struct Books {
  8. char title[50];
  9. char author[50];
  10. char subject[100];
  11. int book_id;
  12. };
  13.  
  14. int main() {
  15. struct Books Book1; // Declare Book1 of type Book
  16. struct Books Book2; // Declare Book2 of type Book
  17.  
  18. // book 1 specification
  19. strcpy( Book1.title, "Learn C++ Programming");
  20. strcpy( Book1.author, "Chand Miyan");
  21. strcpy( Book1.subject, "C++ Programming");
  22. Book1.book_id = 6495407;
  23.  
  24. // book 2 specification
  25. strcpy( Book2.title, "Telecom Billing");
  26. strcpy( Book2.author, "Yakit Singha");
  27. strcpy( Book2.subject, "Telecom");
  28. Book2.book_id = 6495700;
  29.  
  30. // Print Book1 info
  31. printBook( Book1 );
  32.  
  33. // Print Book2 info
  34. printBook( Book2 );
  35.  
  36. return 0;
  37. }
  38. void printBook( struct Books book ) {
  39. cout << "Book title : " << book.title <<endl;
  40. cout << "Book author : " << book.author <<endl;
  41. cout << "Book subject : " << book.subject <<endl;
  42. cout << "Book id : " << book.book_id <<endl;
  43. }
Success #stdin #stdout 0s 4444KB
stdin
Standard input is empty
stdout
Book title : Learn C++ Programming
Book author : Chand Miyan
Book subject : C++ Programming
Book id : 6495407
Book title : Telecom Billing
Book author : Yakit Singha
Book subject : Telecom
Book id : 6495700