ファイルを配列に読み込んでいます。各文字を読み取っていますが、テキストファイルの改行も読み取るという問題が発生します。
これは数独ボードです。文字を読み取るためのコードは次のとおりです。
bool loadBoard(Square board[BOARD_SIZE][BOARD_SIZE])
{
ifstream ins;
if(openFile(ins)){
char c;
while(!ins.eof()){
for (int index1 = 0; index1 < BOARD_SIZE; index1++)
for (int index2 = 0; index2 < BOARD_SIZE; index2++){
c=ins.get();
if(isdigit(c)){
board[index1][index2].number=(int)(c-'0');
board[index1][index2].permanent=true;
}
}
}
return true;
}
return false;
}
私が言ったように、ファイルを読み取り、画面に表示しますが、 \n に遭遇したときに正しい順序ではありません