Need to skip newline char (\n) from input file
        Posted  
        
            by igor
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by igor
        
        
        
        Published on 2010-04-01T00:34:09Z
        Indexed on 
            2010/04/01
            0:43 UTC
        
        
        Read the original article
        Hit count: 461
        
I am reading in a file into an array. It is reading each char, the problem arises in that it also reads a newline in the text file.
This is a sudoku board, here is my code for reading in the 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;
}
like i said, it reads the file, displays on screen, just not in correct order when it encounters the \n
© Stack Overflow or respective owner