I am reading a file into an array. It reads every char, the problem is that it also reads a new line in a text file.
This is sudoku board, here is my code for reading in char:
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;
}
as I said, it reads the file, displays on the screen, but not in the correct order when it encounters \ n
source
share