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.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 1PE
icon
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
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++;
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
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning