Question: Please can you correct this error for me . This gets the correct answers, but the assignment specifically requires that the structures be allocated dynamically,

Please can you correct this error for me. This gets the correct answers, but the assignment specifically requires that the structures be allocated dynamically, and that the array holds pointers to the structures. This program has an array of stPlease can you correct this error for me. This gets the correctanswers, but the assignment specifically requires that the structures be allocated dynamically,ructures, no dynamic allocation and no array of pointers. Write in C++. Thanks

Labo3 #include #include #include using namespace std; struct Product { int product; string Product Name; double UnitPrice; int Unit Sold; }; int main() { struct Product element [100]; int i = 0, j; int total_products; ifstream labFile ("sales.txt"); while (!labFile.eof()) { labFile >> element[i].product; labFile >> element[i]. Product_Name; labFile >> element[i]. UnitPrice; labFile >> element[i]. UnitSold; i++; } total_products = i; for (i = 0; i element[j]. Unit Price * element[j]. Unitsold) { int tempNumber element[i].product; element[i].product element[j].product; element[j].product = tempNumber; = string tempName = element[i]. Product_Name; element[i]. Product_Name = element[j]. Product_Name; element[j]. Product_Name = tempName; double temp Price = element[i]. UnitPrice; element[i]. UnitPrice element[j]. UnitPrice; element[j]. UnitPrice = tempPrice; int tempunits = element[i]. Unitsold; element[i]. Unitsold element[j]. Unitsold; element[j]. UnitSold = tempUnits; } } } //printing cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!