How do you pass an array of structures by reference?

cpp.sh/6u2uu

I'm trying to figure out how to properly pass an array of structures by reference.
I want the music[MAX] array to pass into the openMusicStore() function and inherit the contents back into int main(). What am I doing wrong?
Arrays are passed by reference by default - they don't even support copy/value semantics.

EDIT: Whoops, I didn't notice the link to your code because it wasn't automatically formatted as a link by the forum. MiiNiPaa caught it though.
Last edited on
Your code has a problem: you are passing array pointer to your funtion, but you never use it. Instead you define your own array with same name hiding passed one and later you are doing changes to local array.
Delete lines 29-30.

Also on line 23 you are not passing array, you are passing a single value (operator[] extracts value from array) which is additionally out of bounds for array. To pass a variable, you should just write it name.
Topic archived. No new replies allowed.