• Advertisement
Sign in to follow this  

Passing a 2D array by Reference

This topic is 2931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
Sign in to follow this  

  • Advertisement