I am doing exercises from a book and it asks that I, "use _new_ to allocate an array [of structures]," I have done it this way:
Code:
struct CandyBar // define CandyBar structure
{
char name [20];
float weight;
unsigned int calories;
};
int main()
{
CandyBar * pEaster; // make pointer to Candy bar type
pEaster = new CandyBar[3]; //allocate mem for 3 CandyBar's
delete [] pEaster; // free memory
return 0;
}
But then I can't figure out how to assign values to the structures' elements. Any help would be greatly appreciated.
-cjam