void GameBoard::enterShips()
{
char location[1];
int ships = 0;
int count = 1;
while(ships < NUM_SHIPS)
{
cout << "Enter a location for Ship " << count << ": ";
cin >> location;
cout << endl;
Grid[location[0]][location[1]] = SHIP;
ships++;
count++;
}
}
我正在写一个战舰游戏。我有电路板布局工作和计算机随机生成的船只。现在我正在研究这种方法来提示用户输入船的坐标当我运行程序时,它允许我输入5艘船。当我进入第六艘船时,它给了我这个错误。堆栈周围的变量''已损坏
围绕可变位置的栈被破坏。
我在网上寻找答案,并没有发现任何独家。
任何帮助,将不胜感激。
而是试着去'字符的位置[1] [2];' - 这会给你一个1×2阵列(索引:0 ] [0]和[0] [1]) – RageD 2011-02-27 21:02:25