Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Codedummie

How to pass 2-dim array to function?

This topic is 5740 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

I''m looking for a way to pass a 2-dimensional array to a function/class and can use it there (c/c++). I don''t want to convert that to a 1-dimensional array and pass it with the pointer. Is this possible?

Share this post


Link to post
Share on other sites
Advertisement
void ShowContents(int array[][5])
{
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 5; j++)
cout << array[ i ] [ j ] << endl;

cout << endl;

}

}

This function will work assumming you have a 5x5 array


EDIT: [ i ] was interpreted as italic


[edited by - ph33r on March 30, 2003 1:51:55 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!