I need help with this problem. The assignment says: "Do programming Exercise 6, but instead of declaring an array of three CandyBar structure, use new to allocate the array dynamically".
Here is assignment 6:
#include <iostream>
using namespace std;
struct CandyBar {
char candyName[25];
double candyAmount;
int twoCandyWeight;
};
int main(){
CandyBar detailOfCandy[3] = {
{"Donkey",
2.5,
200},
{"Monkey", 4.4, 100},
{"Honkey", 3.3, 50}
};
cout << "First CandyBar: " << detailOfCandy[0].candyName << "Second CandyBar: "<<detailOfCandy[1].candyName <<" Third CandyBar: "
<< detailOfCandy[2].candyName;
cin.get();
cin.get();
return 0;
}
How do I make this happend without ruinning all that "beautifull code"? Or atleast give me direction/explation for it please :). Hope someone can help me