Multi Dimensional Run-Time Check Failure #3 - The variable 'testarray' is being used without being initialized

I'm trying to learn how to work with Multi Dimensional Arrays (As well as all of C++ of course) but everytime I do anything with them, they will always have some kind of error. One of the them is that it always out puts absolutly random numbers, but the important problem is that it will totally crash and pop up with alot of wierd stuff along with a window saying "Run-Time Check Failure #3 - The variable 'testarray' is being used without being initialized" its not that common thing that happens that just let you know there were a few errors, just everything goes a bit crazy in the ide. Theres been all kinds of codes I've been trying out with MD arrays which are now deleted but the only one I have right now that I can show is this.

#include <iostream>
using namespace std;

int main()
{
int testarray[3] [5];
{{'5', '3', '7', '2', '4';}
{'2', '3', '2', '3', '2';}
{'2', '3', '2', '3', '2';}
}
cout << testarray[3][2]+5;
system ("PAUSE");
return 0;
}

I As ussual, help is very much appreciated
These statements are invalid.

1
2
3
4
5
6
int testarray[3] [5];
 {{'5', '3', '7', '2', '4';}
 {'2', '3', '2', '3', '2';}
 {'2', '3', '2', '3', '2';}
 }
 cout << testarray[3][2]+5;


That to do correctly what you want you should write

1
2
3
4
5
int testarray[3] [5] =  { { '5', '3', '7', '2', '4' },
                          { '2', '3', '2', '3', '2' },
                          { '2', '3', '2', '3', '2' } };

 cout << testarray[2][2]+5;
Last edited on
Thank you!! It solved the prob!
Topic archived. No new replies allowed.