Sign in to follow this  
RogerThat123

Passing a 2D array by Reference

Recommended Posts

RogerThat123    100
How can I do this. I googled it and saw something about using a pointer int **myArray or something. I haven't managed to get anything working yet..

void ClearGrid(int Grid[3][3]);

int Grid[3][3];

int main ()
{
    ClearGrid(Grid); // I need to somehow return Grid back to the program
}

Share this post


Link to post
Share on other sites
clashie    632
void ClearGrid(int* p)
{
*(p + 1) = 100; //grid[0][1] ends up as 100
};



int main()
{
int Grid[3][3];

ClearGrid(*Grid);

return 0;
}


maybe this is what you saw?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this