I am trying to write a program that will help play Sudoku. It needs to read in the data from a txt file using a get. And follow the letter commands N= new game, A= add character, R= remove d= display board. What I am having difficulty with at the moment is reading the board into a 2d array board. After N it should read in the next characters including the blanks into an array. I can't seem to get the right numbers in the right format. The input will be attached below thanks for any help
#include<iostream>
#include<fstream>
#include<iomanip>
usingnamespace std;
constint MAXCOL = 9;
constint MAXROW = 9;
void dis_board(char arr[][MAXCOL]);
void new_board(char arr[][MAXCOL], char ch, ifstream& in);
int main()
{
char board[MAXROW][MAXCOL];
int row, col, num_ele = 0, num1;
char ch1;
ifstream infile;
infile.open("mp6in.txt");
infile.get(ch1);
while (infile)
{
if (ch1 == 'N')
infile.ignore(10, '\n');
infile.get(ch1);
new_board(board, ch1, infile);
//dis_board(board);
infile.get(ch1);
}
dis_board(board);
}
void dis_board(char arr[][MAXCOL])
{
for (int i = 0; i < MAXROW; i++)
{
for (int j = 0; j < MAXCOL; j++)
cout << arr[i][j] << " ";
cout << endl;
}
}
void new_board(char arr[][MAXCOL],char ch, ifstream& in)
{
for (int i = 0; i < MAXROW; i++)
{
for (int j = 0; j < MAXCOL; j++)
{
in >> (arr[i][j]);
}
}
}
Input file
N
145369287
629785431
783412569
567148392
938527 14
214936758
851 74623
492853 76
376291845
D
R 7 7
A 7 7 9
A 7 4 6
A 8 7 1
A 5 7 6
D
N
6892731
921653847
57314 269
154 6972
689271453
742395 81
257834196
19 762538
365 972
D
A 9 9 4
A 1 1 4
A 8 3 4
A 1 9 5
A 9 1 8
A 4 5 8
A 6 7 6
A 3 6 8
A 4 1 3
A 9 5 1
D
N
2 4 63
421
9 6 42
9 7 6
35 28
7 1 5
59 6 8
857
18 3 5
D
A 3 2 4
A 4 1 7
A 8 8 8
A 5 5 5
A 6 9 2
A 3 7 9
A 5 8 9
A 0 4 9
A 3 0 3
A 9 1 0
D
A 2 8 5
A 5 9 7
D
What is the purpose of line 24? It reads the first character of the new sudoku board so the new_board will start reading from the second character (the 4).