2-Dimensional Array not working?

I have this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int someArray[2][5] = {'O'};
    for(int i; i < 2; i++)
    {
        for(int j; j < 5; j++)
            cout << someArray[i][j];
        cout << endl;
    }
}

When I compile it, nothing appears. What am I doing wrong?
You need to give your variables an initial value:
1
2
3
for(int i; i < 2; i++) // i starts with a random value

for(int i = 0; i < 2; i++) // i starts from 0 
Last edited on
Thank you. I assumed that all variables started at 0.
Topic archived. No new replies allowed.