Problem with giving value to arrays

I want to make something will shows up like:
1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D

I am trying to use 2-D arrays.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>

using namespace std;

void seat(char a[7][5]);

int main()
{
    char a[7][5];
    seat(a);
    return 0;
}

void seat(char a[7][5])
{
    for(int i =0;i<7;i++)
    {
        for(int x =0;i<5;i++)
        {
            switch (x)
            {
            case 1:
            a[i][x] = 'A';
            break;

            case 2:
            a[i][x] = 'B';
            break;

            case 3:
            a[i][x] = 'C';
            break;

            case 4:
            a[i][x] = 'D';
            break;

            default:
            break;
            }
        }
    }

    for(int i =0;i<7;i++)
    {
        for(int x =0;i<5;i++)
        {
            cout << a[i][x] << " ";

        }

        cout << endl;
    }

}


something weird just comes out, is it total wrong or just have some problem with the coding?
Line 46:
 
    for(int x = 0; i < 5; i++)    //Change i's to x's  


Edit:
Also, you never assigned a value when x = 0, so it still holds some junk value.
Last edited on
Thank you, fixed
Topic archived. No new replies allowed.