#include "stdafx.h"
#include <iostream>
using namespace std;
#define NUMBER_OF_PLAYERS 3
int _tmain(int argc, _TCHAR* argv[])
{
int my2DArray[3][3];
my2DArray[1][1] = 1;
my2DArray[1][2] = 2;
my2DArray[1][3] = 3;
my2DArray[2][1] = 4;
my2DArray[2][2] = 5;
my2DArray[2][3] = 6;
my2DArray[3][1] = 7;
my2DArray[3][2] = 8;
my2DArray[3][3] = 9;
for (int y = 0; y < 3; y++)
{
for(int x = 0; x < 3; x++)
{
cout << my2DArray[x][y];
}
cout << endl;
}
return 0;
}
當我運行此C++代碼的變量,會出現一條消息:運行時檢查失敗#2 - 堆棧圍繞變量「my2DArray」是損壞。我檢查了其他線程,但沒有找到答案。我做錯了什麼?運行時檢查失敗#2 - 堆棧圍繞「my2DArray」被損壞
閱讀本文:[「如何在C++中使用數組」](http://stackoverflow.com/questions/4810664/how-do-i-use-arrays-in-c)。 – WhozCraig