I have two questions here , I did the homework assignment in its entirety but I'm wondering if there is an easier way to assign the values to my dynamic array? Is there a reason why I can't use the syntax cArray = { {array1values}, {array2values}, {array3values} }; ?
My compiler kept giving me an error but I didn't understand it.
Also in my for loop it uses the notation : cArray[i].name etc... why isn't it cArray->[i].name ? Is it because an array is an address so an array of structs is really an array of addresses which hold values - and in order to obtain the value at an array index you use bracket notation such as arrayName[i] ? Am I way off? I feel like I'm in over my head with these exercises.
You can use that syntax to initialize your array if you don't use a dynamic array. CandyBar cArray[] = {{"Mocha Munch", 2.3, 250}, ...
If cArray is a pointer cArray[i] is just the same as writing *(cArray + i). I guess it's just convenient to be able to use the same syntax for a pointer as you do with an array.