# Displaying MultiDimensional arrays easily

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

## Recommended Posts

How do you display multidimensional arrays to the console? I can't seem to do it the same way as normal arrays. For example: char blah[2][2]{{'a','b'}{'c',d'}}; cout<<blah; This shows up as some wierd hexadecimal-ish thing. What I want it to show up as would be: ab cd Any idea if this is possible without too much work? Thanks

##### Share on other sites
This isn't supported, you'll need to use a loop
for x = 0 to size_x for y = 0 to size_y    cout << foo[x][y]; next y cout << endl;next x

##### Share on other sites
Thanks for the help, but...
Sorry, but I am a real noob and I don't really understand that.
Here are the parts I need clarification upon:
size_x and size_y
next y and next x

edit
----------------------------------------------------------------
I looked on google and found something that might be related:
size_t and strlen? Dunno.

##### Share on other sites
Quote:
 Original post by elitentityThanks for the help, but...Sorry, but I am a real noob and I don't really understand that.Here are the parts I need clarification upon:size_x and size_ynext y and next x

just some pseudo-code, sorry for being cryptic.

size_x and size_y are the dimentions of your array, in this case, 2 by 2.

the for loops are done in BASIC style, because I like basic, dammit. [smile]

here's the C++ code
#include <iostream>using namespace std;int main(){ char blah[2][2] = {{'a', 'b'}, {'c', 'd'}}; for(int y = 0; y < 2; y++)  {     for(int x = 0; x < 2; x++)         {         cout << blah[x][y];         }      cout << endl;   }}

That should compile.

Basically, I'm looping through all the letters and printing them out. After each row, I print a return(endl) which resets it for the next row.

##### Share on other sites
Thanks a lot. It works (of course).