How to pass a pointer to an array by reference?

I have a struct which has an array inside of it:

struct someStruct{
int structArray[999];


Now when I want to access that array, I have the following:


But now I want to pass structArray to this function by reference so that it can adjust the array as needed and I can continue to use the array back in my caller function:

void adjustArray(void *& someArray){}

How do I accomplish this?
You can use something like the following:

void adjustArray(int (&someArray)[999]) {}

The type of object you want to pass into the function is an array of integers, or a pointer to an integer. It's perfectly legal to have a reference to a pointer, so your function prototype would be:

void adjustArray(int*& someArray) {}

Yeah, the mixture of * and & symbols looks a bit messy, but it's perfectly fine.
Last edited on
Topic archived. No new replies allowed.