「迷路」を表すファイル内の 7x15 のテキスト ブロックを読み取るコードを書いています。
#include <iostream>
#include <fstream>
#include <string>
#include "board.h"
int main()
{
char charBoard[7][15]; //the array we will use to scan the maze and modify it
ifstream loadMaze("maze"); //the fstream we will use to take in a maze
char temp; //our temperary holder of each char we read in
for(int i = 0;i < 7; i++)
{
for(int j = 0; j < 15; j++)
{
temp= loadMaze.get();
charBoard[i][j] = temp;
cout << charBoard[i][j]; //testing
}
cout << endl;
}
return 0;
}
これは私の最初のドラフトでしたが、戻ってきたのでうまくいきませんでしたか? 読み取った各文字に対して。これは迷路の im テストです:
############ # ############ # # ######### #### # ! # ############
編集: cout はこれを印刷しています:
############ # ############ # # ######## #### # ! # ########
\n をエスケープしていませんか?
私は数時間コーディングを行ってきたので、今私をつまずかせているのは、私が見つけていない単純な間違いだと思います. ありがとう!