-2
每次我在Visual Studio 2015中運行此代碼時,它都會顯示錯誤標識符「treasureLocation」未定義......我做錯了什麼?陣列:標識符「array」未定義
int main()
{
int gridSize [2];
int gridX = 0;
int gridY = 0;
int treasureLoaction[2];
int end;
std :: cout << "what size grid would you like to play on?" << std :: endl;
std :: cin >> gridSize [1];
std :: cin >> gridSize [2];
treasureLocation[1] = rand() % gridSize[1] + 1;
treasureLocation[2] = rand() % gridSize[2] + 1;
while (gridY < gridSize[2]) {
gridY++;
while (gridX < gridSize[1]) {
std::cout << "* ";
gridX++;
}
std::cout << "" << std::endl;
gridX = 0;
};
std::cout << treasureLoaction;
std::cin >> end;
return 0;
}
'std :: cout << treasureLoaction;'你不能用數組來做到這一點。雖然你拼寫錯了也。 – drescherjm
'treasureLoaction!= treasureLocation',作爲一個簡單的印刷錯誤關閉。 – Jack