lease due in c++ A sample run is as follows (be sure to format your output): BOOK INFORMATION In Search of Lost Time Marcel Proust 1913 $17.99 Ulysses James Joyce 1904 $21.95 Don Quixote Miguel de Cervantes 1605 $21.49 One Hundred Years of Solitude Gabriel Garcia Marquez 1982 $28.09 The Great Gatsby F. Scott Fitzgerald 1925 $10.99 This is files from the picture: //Book.h - The Book class/structure #ifndef _BOOK_H_ #define _BOOK_H_ //GIVEN: some useful constants const int MAX_STRING = 64; const int MAX_STREAM = 128; const int NUM_BOOKS = 5;//Let's read only five books from the file //TODO: Create a class or structure called Book // If you create a class, you can make all variables public #endif _BOOK_H_ This is Book.cpp : [1:27 a.m., 2023-03-13] Amjd: //Book.cpp - function definitions for the Book class #include "Book.h" //Create a function to extract a string from the stream. //It will be called four times from main() to extract the //NAME, AUTHOR, YEAR OF PUBLICATION, and PRICE. //Use below as a guide if you wish //Extracting NAME: // NAME;AUTHOR;YEAR;PRICE; // ^ ^ // | | //dataBeginPtr dataEndPtr //Extracting AUTHOR: // NAME;AUTHOR;YEAR;PRICE; // ^ ^ // | | // dataBeginPtr dataEndPtr //Extracting YEAR OF PUBLICATION: // NAME;AUTHOR;YEAR;PRICE; // ^ ^ // | | // dataBeginPtr dataEndPtr //Extracting PRICE: // NAME;AUTHOR;YEAR;PRICE; // ^ ^ // | | // dataBeginPtr dataEndPtr this is BookMain.cpp from the picture: //BookMain.cpp - main function for Book #define _CRT_SECURE_NO_WARNINGS #include //TODO: Add any other required header files #include "Book.h" int main(int argc, char* argv[]) { int retVal = 0; if (argc != 2) { printf("Usage: BookMain.exe Book.txt"); return -1; } FILE* fp = fopen(argv[1], "r"); //TODO: Declare an array of NUM_BOOKS objects of type Book for (int i = 0; i < NUM_BOOKS; ++i) { char bookData[MAX_STREAM] = { 0 }; fscanf_s(fp, "%[^\n]s", bookData, MAX_STREAM);//Read an entire line from the file and store in bookData while (fgetc(fp) != '\n');//clear out the carriage return //NAME;AUTHOR;YEAR;PRICE; //TODO: Call the extraction function four times too extract the NAME, AUTHOR, YEAR, and PRICE using // the following pointers. Store the information into the array of Book objects one at a time: char* leftPtr = bookData;//&bookData[0] char* rightPtr = nullptr;//C++ equivalent of NULL } fclose(fp); //TODO: print out all the information for all the books return 0; }
lease due in c++ A sample run is as follows (be sure to format your output): BOOK INFORMATION In Search of Lost Time Marcel Proust 1913 $17.99 Ulysses James Joyce 1904 $21.95 Don Quixote Miguel de Cervantes 1605 $21.49 One Hundred Years of Solitude Gabriel Garcia Marquez 1982 $28.09 The Great Gatsby F. Scott Fitzgerald 1925 $10.99 This is files from the picture: //Book.h - The Book class/structure #ifndef _BOOK_H_ #define _BOOK_H_ //GIVEN: some useful constants const int MAX_STRING = 64; const int MAX_STREAM = 128; const int NUM_BOOKS = 5;//Let's read only five books from the file //TODO: Create a class or structure called Book // If you create a class, you can make all variables public #endif _BOOK_H_ This is Book.cpp : [1:27 a.m., 2023-03-13] Amjd: //Book.cpp - function definitions for the Book class #include "Book.h" //Create a function to extract a string from the stream. //It will be called four times from main() to extract the //NAME, AUTHOR, YEAR OF PUBLICATION, and PRICE. //Use below as a guide if you wish //Extracting NAME: // NAME;AUTHOR;YEAR;PRICE; // ^ ^ // | | //dataBeginPtr dataEndPtr //Extracting AUTHOR: // NAME;AUTHOR;YEAR;PRICE; // ^ ^ // | | // dataBeginPtr dataEndPtr //Extracting YEAR OF PUBLICATION: // NAME;AUTHOR;YEAR;PRICE; // ^ ^ // | | // dataBeginPtr dataEndPtr //Extracting PRICE: // NAME;AUTHOR;YEAR;PRICE; // ^ ^ // | | // dataBeginPtr dataEndPtr this is BookMain.cpp from the picture: //BookMain.cpp - main function for Book #define _CRT_SECURE_NO_WARNINGS #include //TODO: Add any other required header files #include "Book.h" int main(int argc, char* argv[]) { int retVal = 0; if (argc != 2) { printf("Usage: BookMain.exe Book.txt"); return -1; } FILE* fp = fopen(argv[1], "r"); //TODO: Declare an array of NUM_BOOKS objects of type Book for (int i = 0; i < NUM_BOOKS; ++i) { char bookData[MAX_STREAM] = { 0 }; fscanf_s(fp, "%[^\n]s", bookData, MAX_STREAM);//Read an entire line from the file and store in bookData while (fgetc(fp) != '\n');//clear out the carriage return //NAME;AUTHOR;YEAR;PRICE; //TODO: Call the extraction function four times too extract the NAME, AUTHOR, YEAR, and PRICE using // the following pointers. Store the information into the array of Book objects one at a time: char* leftPtr = bookData;//&bookData[0] char* rightPtr = nullptr;//C++ equivalent of NULL } fclose(fp); //TODO: print out all the information for all the books return 0; }
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
Please due in c++
A sample run is as follows (be sure to format your output):
BOOK INFORMATION
In Search of Lost Time Marcel Proust 1913 $17.99
Ulysses James Joyce 1904 $21.95
Don Quixote Miguel de Cervantes 1605 $21.49
One Hundred Years of Solitude Gabriel Garcia Marquez 1982 $28.09
The Great Gatsby F. Scott Fitzgerald 1925 $10.99
This is files from the picture:
//Book.h - The Book class/structure
#ifndef _BOOK_H_
#define _BOOK_H_
//GIVEN: some useful constants
const int MAX_STRING = 64;
const int MAX_STREAM = 128;
const int NUM_BOOKS = 5;//Let's read only five books from the file
//TODO: Create a class or structure called Book
// If you create a class, you can make all variables public
#endif _BOOK_H_
This is Book.cpp :
[1:27 a.m., 2023-03-13] Amjd: //Book.cpp - function definitions for the Book class
#include "Book.h"
//Create a function to extract a string from the stream.
//It will be called four times from main() to extract the
//NAME, AUTHOR, YEAR OF PUBLICATION, and PRICE.
//Use below as a guide if you wish
//Extracting NAME:
// NAME;AUTHOR;YEAR;PRICE;
// ^ ^
// | |
//dataBeginPtr dataEndPtr
//Extracting AUTHOR:
// NAME;AUTHOR;YEAR;PRICE;
// ^ ^
// | |
// dataBeginPtr dataEndPtr
//Extracting YEAR OF PUBLICATION:
// NAME;AUTHOR;YEAR;PRICE;
// ^ ^
// | |
// dataBeginPtr dataEndPtr
//Extracting PRICE:
// NAME;AUTHOR;YEAR;PRICE;
// ^ ^
// | |
// dataBeginPtr dataEndPtr
this is BookMain.cpp from the picture:
//BookMain.cpp - main function for Book
#define _CRT_SECURE_NO_WARNINGS
#include
//TODO: Add any other required header files
#include "Book.h"
int main(int argc, char* argv[]) {
int retVal = 0;
if (argc != 2) {
printf("Usage: BookMain.exe Book.txt");
return -1;
}
FILE* fp = fopen(argv[1], "r");
//TODO: Declare an array of NUM_BOOKS objects of type Book
for (int i = 0; i < NUM_BOOKS; ++i) {
char bookData[MAX_STREAM] = { 0 };
fscanf_s(fp, "%[^\n]s", bookData, MAX_STREAM);//Read an entire line from the file and store in bookData
while (fgetc(fp) != '\n');//clear out the carriage return
//NAME;AUTHOR;YEAR;PRICE;
//TODO: Call the extraction function four times too extract the NAME, AUTHOR, YEAR, and PRICE using
// the following pointers. Store the information into the array of Book objects one at a time:
char* leftPtr = bookData;//&bookData[0]
char* rightPtr = nullptr;//C++ equivalent of NULL
}
fclose(fp);
//TODO: print out all the information for all the books
return 0;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education