Issues with displaying array

I'm trying to make the values of my array display in rows with 'm_x' length, but it isn't organizing as intended...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int m_x = 5;  //for testing
    int m_y = 5;    //for testing
    char m_build [m_x] [m_y] {
        {3,1,0,1,2},//for testing
        {3,1,0,1,2},//for testing
        {3,1,0,1,2},//for testing
        {3,1,0,1,2},//for testing
        {3,1,0,1,2} //for testing
    };
    for (int i = 0; i < m_x; i++) {
        for (int j = 0; j < m_y; j++) {
            if (i != m_x / 5 ) { //for testing
                cout << m_build [i] [j];
            }
            else {
                cout << "\n" << m_build [i] [j];
            }
        }
    }
What is the expected result vs. what you are getting?
Expected:
3 1 0 1 2
3 1 0 1 2
3 1 0 1 2
3 1 0 1 2
3 1 0 1 2

Getting:
3 1 0 1 2
3
1
0
1
2 3 1 0 1 2 3 1 0 1 2 3 1 0 1 2

What about this:

1
2
3
4
5
6
7
    for (int i = 0; i < m_x; i++) {
        for (int j = 0; j < m_y; j++) {
            cout << m_build [i] [j];
            if (j == m_x - 1)
            	cout << endl;
        }
    }


which will get you the output you want, but I think what you're asking for is "what if the length of m_x doesn't match m_y"?

What do you want to have happen if that is the case? Or am I misunderstanding your request?
I'm actually trying to use it to create a map of sorts...
It would start out blank (0) and the character (later in the script) is able to move around the array.
In order to do this properly, the array needs to be organized in an x and y format. (m_x, m_y)

@topic
That worked perfectly!
Many thanks to you sir! :D
Topic archived. No new replies allowed.