Reading txt-file into array

I use this code to read from text file:
1
2
3
4
5
6
7
8
9
10
11
int read_file()
{
  char board[7][11];
  int n,m;

  ifstream inFile("file.txt");
  for(n=0; n<7; n++) 
     for(m=0; m<11; m++)
        inFile>>board[n][m];
  return 1;
}


The txt-file looks like this: ( The stars are really empty space characters. Had to replace them with stars for posting.)
1|*******|1
2|******5|2
3|*4****5|3
4|*4***25|4
5|*433325|5
6|*4****5|6
7|*******|7

I want that my program shows contents of array like they are shown in txt-file.
But after reading it my program shows it like this:
1||12|5|23|
45|34|425|4
5|433325|56
|45|67||6|4
5|433325|56
|45|67||6|7
7| |7

If there are no empty spaces between numbers the array looks like it is supposed look like.

This is how I print contents of array:
1
2
3
4
5
6
7
8
9
10
void show_board();
{
   int n,m;
   for(n=0; n<7; n++)
   {
   cout<<endl;
   for(m=0; m<11; m++)
      cout<<board[n][m]<<" ";
   }
}


What should I do to prevent the array from breaking like shown here?
You should put it into a string and use string copy.
www.cplusplus.com/reference/string/string/copy/
Use noskipws stream maniupulator
1
2
3
4
5
6
7
8
  for(n=0; n<7; n++)
     for(m=0; m<11; m++)
        {
            inFile>>noskipws>>board[n][m];
            
            if(board[n][m]=='\n' || board[n][m]=='\r') // ignore newline characters
                m--;
        }


http://www.cplusplus.com/reference/iostream/manipulators/noskipws/
Thanks Null, that solved it!
Topic archived. No new replies allowed.