I am working on a C++ workshop and have been facing this error message at the addCustomer function. Would you please explain the reason of it and how can I fix this issue please? Thank you very much.
I am working on a C++ workshop and have been facing this error message at the addCustomer function. Would you please explain the reason of it and how can I fix this issue please? Thank you very much.
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
I am working on a C++ workshop and have been facing this error message at the addCustomer function. Would you please explain the reason of it and how can I fix this issue please? Thank you very much.
![error message screenshot:
// Adds a Customer to the dynamically allocated memory of customers in CustomersRecord
void addCustomer (CustomersRecord& t_rec, const Customers& c_rec) {
t_rec.ptr_rec = new Customers [t_rec.no0fRecords];
t_rec.ptr_rec[t_rec.no0fRecords] = _c_rec;
}
//It prints a row number with a period
void display(const CustomersRecord& t_
int i;
main
t_rec.no0fRecords++;
#include <iostream>
#include "Customer.h"
using namespace std;
using namespace sdds;
int main() {
bool Check = false;
Customers c_rec;
EmptyRecord (c_rec);
CustomersRecord t_rec;
EmptyRecord (t_rec);
cout << "__
while (!Check) {
cout << endl<<"Enter customer information (to exit, press Enter): " << endl;
if (read(c_rec)) {
addCustomer (t_rec, c_rec);
}
else {
}
}
constexpr sdds::Customers &sdds::Customers::operator= (const sdds::Customers &)
+1 overload
Search Online
C6386: Buffer overrun while writing to 't_rec.ptr_rec'.
Customers records entry
Check = true;
display(t_rec);
cout <<
cout <<
}
cout <<
<< endl;
cout << "
Users' tweets report
<< endl;
cout << " user name, likes, re-tweets, replies, share videos (y/n)" << endl;
cout <<
<< endl;
<< endl;
Report was successfully created
<< endl;
" << endl;
delete[] t_rec.ptr_rec;
cout << "Dynamically allocated memory was successfully deallocated" << endl;
cout <<
<< endl;
ei](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb7b26484-772b-4284-af5a-fa2f3fa080bf%2F536f26da-8104-4812-9520-b545ecf5ddd6%2F8gioma_processed.jpeg&w=3840&q=75)
Transcribed Image Text:error message screenshot:
// Adds a Customer to the dynamically allocated memory of customers in CustomersRecord
void addCustomer (CustomersRecord& t_rec, const Customers& c_rec) {
t_rec.ptr_rec = new Customers [t_rec.no0fRecords];
t_rec.ptr_rec[t_rec.no0fRecords] = _c_rec;
}
//It prints a row number with a period
void display(const CustomersRecord& t_
int i;
main
t_rec.no0fRecords++;
#include <iostream>
#include "Customer.h"
using namespace std;
using namespace sdds;
int main() {
bool Check = false;
Customers c_rec;
EmptyRecord (c_rec);
CustomersRecord t_rec;
EmptyRecord (t_rec);
cout << "__
while (!Check) {
cout << endl<<"Enter customer information (to exit, press Enter): " << endl;
if (read(c_rec)) {
addCustomer (t_rec, c_rec);
}
else {
}
}
constexpr sdds::Customers &sdds::Customers::operator= (const sdds::Customers &)
+1 overload
Search Online
C6386: Buffer overrun while writing to 't_rec.ptr_rec'.
Customers records entry
Check = true;
display(t_rec);
cout <<
cout <<
}
cout <<
<< endl;
cout << "
Users' tweets report
<< endl;
cout << " user name, likes, re-tweets, replies, share videos (y/n)" << endl;
cout <<
<< endl;
<< endl;
Report was successfully created
<< endl;
" << endl;
delete[] t_rec.ptr_rec;
cout << "Dynamically allocated memory was successfully deallocated" << endl;
cout <<
<< endl;
ei
![#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
#include "Customer.h"
#include "Tools.h"
namespace sdds {
Customers* ptr_rec;
// complete
void read (char* str, int len) { // Fully provided
if (cin.peek() == '\n') {
cin.ignore();
}
// complete
}
// Sets Customer data members to an empty state >> ptr_rec (to dynamically store the number of records)
void EmptyRecord (Customers& c_rec) {
c_rec = { '0', 0, 0, 0, '0'};
}
}
cin.getline(str, len);
// Sets CustomersRecord user_name to an empty state >> ptr_rec.user_name (to dynamically store the name)
void EmptyRecord (CustomersRecord& t_rec) {
}
// Requests to enter Customers record, return false if name is empty after enter
bool read(Customers& rec) {
bool check = true;
int i = 0;
char read_user_name = '0';
}
t_rec.ptr_rec = nullptr;
t_rec.no0fRecords = 0;
cout<<"Enter User name : ";
read_user_name = cin.get();
if (read_user_name == '\n') {
check = false;
}
else {
for (i = 0; read_user_name != '\n'; i++) {
rec.user_name[i] = read_user_name;
read_user_name = cin.get();
}
cout << "Enter likes_count: ";
cin >> rec.likes_count;
cout << "Enter retweets_count: ";
cin >> rec.retweets_count;
cout << "Enter replies_count: ";
cin >> rec.replies_count;
cout << "Enter share videos (y/n): ";
cin >> rec.share_videos;
cout << endl;
while (cin.get() != '\n');
}
return check;
// Adds a Customer to the dynamically allocated memory of customers in CustomersRecord
void addCustomer (CustomersRecord& t_rec, const Customers& c_rec) {
t_rec.ptr_rec = new Customers [t_rec.no0fRecords];
t_rec.ptr_rec[t_rec.noof Records] = c_rec;
t_rec.no0fRecords++;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb7b26484-772b-4284-af5a-fa2f3fa080bf%2F536f26da-8104-4812-9520-b545ecf5ddd6%2Fxgpaeni_processed.jpeg&w=3840&q=75)
Transcribed Image Text:#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
#include "Customer.h"
#include "Tools.h"
namespace sdds {
Customers* ptr_rec;
// complete
void read (char* str, int len) { // Fully provided
if (cin.peek() == '\n') {
cin.ignore();
}
// complete
}
// Sets Customer data members to an empty state >> ptr_rec (to dynamically store the number of records)
void EmptyRecord (Customers& c_rec) {
c_rec = { '0', 0, 0, 0, '0'};
}
}
cin.getline(str, len);
// Sets CustomersRecord user_name to an empty state >> ptr_rec.user_name (to dynamically store the name)
void EmptyRecord (CustomersRecord& t_rec) {
}
// Requests to enter Customers record, return false if name is empty after enter
bool read(Customers& rec) {
bool check = true;
int i = 0;
char read_user_name = '0';
}
t_rec.ptr_rec = nullptr;
t_rec.no0fRecords = 0;
cout<<"Enter User name : ";
read_user_name = cin.get();
if (read_user_name == '\n') {
check = false;
}
else {
for (i = 0; read_user_name != '\n'; i++) {
rec.user_name[i] = read_user_name;
read_user_name = cin.get();
}
cout << "Enter likes_count: ";
cin >> rec.likes_count;
cout << "Enter retweets_count: ";
cin >> rec.retweets_count;
cout << "Enter replies_count: ";
cin >> rec.replies_count;
cout << "Enter share videos (y/n): ";
cin >> rec.share_videos;
cout << endl;
while (cin.get() != '\n');
}
return check;
// Adds a Customer to the dynamically allocated memory of customers in CustomersRecord
void addCustomer (CustomersRecord& t_rec, const Customers& c_rec) {
t_rec.ptr_rec = new Customers [t_rec.no0fRecords];
t_rec.ptr_rec[t_rec.noof Records] = c_rec;
t_rec.no0fRecords++;
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 2 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