【发布时间】:2014-04-06 20:27:36
【问题描述】:
我正在尝试将二维数组保存到文件中,但它显示为“^L”。如果用户输入 Y 或 y,则程序应该结束,但它正在打印我的二维数组。
//Allow user to quit
cout << "Would you like to quit this game? Enter Y or N: " << endl;
cin >> Choice;
if (Choice == 'Y' || Choice == 'y')
{
ofstream outfile("Map.txt");
for (int row = 0; row < ROWS; row++)
{
for (int col = 0; col < COLS; col++)
outfile << "Here is your map! " << Map[ROWS][COLS] << endl;
}
outfile.close();
}
if (Choice == 'N' || Choice == 'n')
{
// Add code to play the game
PlayTurn(TreasureR, TreasureC, Row, Col, NumMoves);
}
// Print the map for true
PrintMap(Map,true, TreasureR, TreasureC, StartR, StartC, Row, Col);
//End the game
cout << "You finished the Game in " << NumMoves <<" moves.\n";
【问题讨论】:
标签: c++ arrays file multidimensional-array