checkBoard function

So I am working I'm trying to get enforce the rules of Sudoku in my code. I was wondering if I could just implement this test in my editBoard function or make a new function altogether, because if I do need a new function I would probably have to make a new function to get the user input, so when I try running it in the editBoard function I get a segementation fault, is there a way I can just run a series of if statements and loop through my board to see if it's a valid number, checking the rows columns and squares? Here is my code. I made some updates since last time, but just the main help is needed on the editBoard and showValues function. On the showValues function to show possible values, how would you implement this, would you just go through the rows, column, and squares and just somehow get rid of those numbers and then have the remaining numbers still remain? Right now I have only implemented the check for columns, want to make sure it works before I implement rows and squares.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;

void readFile(char sudokuBoard[][9]);
void displayOptions(char sudokuBoard[][9]);
void displayJustOptions();
void justDisplay(char sudokuBoard [][9]);
void display(char sudokuBoard[][9]);
void interact(char sudokuBoard[][9]);
void editBoard(char sudokuBoard[][9]);
void showValue (char sudokuBoard[][9]);
void writeFile(char sudokuBoard[][9]);

/**********************************************************************
 * driver program for the functions below
 ***********************************************************************/
int main()
{
   char sudokuBoard[9][9];
   
   readFile(sudokuBoard);
   displayOptions(sudokuBoard);
   interact(sudokuBoard);
   return 0;
}

/**********************************************************************
 * reads the file back into our board[][] array.
 ***********************************************************************/
void readFile(char sudokuBoard[][9])
{
   char initialFile[256];

   ifstream fin;
   
   cout << "Where is your board located? ";
   cin >> initialFile;

   fin.open(initialFile);
   if (fin.fail())
   {
      cout << "Error reading file";
   }
    
   for (int row = 0; row < 9; row++)
   {
      for (int col = 0; col < 9; col++)
      {
         fin >> sudokuBoard[col][row];
      }
   }
   fin.close();
}

/**********************************************************************
 * displays the suduko board and replaces zeros with null characters.
 ***********************************************************************/
void display(char sudokuBoard[][9])
{
   // display sudoku board row by row
   cout << endl
        << "   A B C D E F G H I\n";
   
   for (int row = 0; row < 9; row++)
   {
      cout << row + 1 << "  ";
      for (int col = 0; col < 9; col++)
      {
         if (sudokuBoard[col][row] == '0')
            cout << " ";
         else 
            cout << sudokuBoard[col][row];
         if (col == 2 || col == 5)
            cout << "|";
         else if (col != 8)
            cout << " ";
      }
         
      if (row == 2 || row == 5)
         cout << "\n   -----+-----+-----\n";
      else
         cout << endl;
   }
}

/**********************************************************************
 * displays the suduko board and replaces zeros with null characters.
 ***********************************************************************/
void justDisplay(char sudokuBoard [][9])
{
   cout << "   A B C D E F G H I\n";

   for (int row = 0; row < 9; row++)
   {
      cout << row + 1 << "  ";
      for (int col = 0; col < 9; col++)
      {
         if (sudokuBoard[col][row] == '0')
            cout << " ";
         else 
            cout << sudokuBoard[col][row];
         if (col == 2 || col == 5)
            cout << "|";
         else if (col != 8)
            cout << " ";
      }

      if (row == 2 || row == 5)
         cout << "\n   -----+-----+-----\n";
      else
         cout << endl;
   }
}

/**********************************************************************
 * displays the suduko board and replaces zeros with null characters.
 ***********************************************************************/
void displayJustOptions()
{
   cout << "Options:\n"
        << "   ?  Show these instructions\n"
        << "   D  Display the board\n"
        << "   E  Edit one square\n"
        << "   S  Show the possible values for a square\n"
        << "   Q  Save and Quit\n";
   cout << endl;
}

/**********************************************************************
 * displays the suduko board and replaces zeros with null characters.
 ***********************************************************************/
void displayOptions(char sudokuBoard[][9])
{
   cout << "Options:\n"
        << "   ?  Show these instructions\n"
        << "   D  Display the board\n"
        << "   E  Edit one square\n"
        << "   S  Show the possible values for a square\n"
        << "   Q  Save and Quit\n";
   display(sudokuBoard);
}

/**********************************************************************
 * function displays the options the gamer can choose from and proceed
 * to go to the option they choose.
 ***********************************************************************/
void interact(char sudokuBoard[][9])
{
   char option;
   while (true)
   {
      cout << endl;
      cout << "> ";
      cin >> option;
      if (option == '?')
         displayJustOptions();
      else if (option == 'D' || option == 'd')
         justDisplay(sudokuBoard);
      else if (option == 'S' || option == 's')
         showValue(sudokuBoard);
      else if (option == 'E' || option == 'e')
         editBoard(sudokuBoard); 
      else if (option == 'Q' || option == 'q')
         break;
   }
   writeFile(sudokuBoard);
}


/**********************************************************************
 * function will show all possible values for the coordinates entered
 ***********************************************************************/
void showValue(char sudokuBoard[][9])
{
   char letter;
   int number;
   
   cout << "What are the coordinates of the square: ";
   cin >> letter >> number;

   toupper(letter);
   
   if (sudokuBoard[letter - 65][number - 1] != '0')
   {
      cout << "ERROR: Square \'" << letter << number <<
         "\'" << " is filled\n";
   }

   else
   {
      cout << "The possible values for " << letter << number
           << " are";

   }
} 
   
/**********************************************************************
 * function will edit a coordinate of the game board based on what
 * was entered
 ***********************************************************************/
void editBoard(char sudokuBoard[][9])
{
   char letter;
   int number; 
   int value;
   int row;
   int col;

   cout << "What are the coordinates of the square: ";
   cin >> letter >> number;

   letter = toupper(letter);
   

   if (sudokuBoard[letter - 65][number - 1] != '0')
   {
      cout << "ERROR: Square \'" << letter << number <<
         "\'" << " is filled\n";
   }
   else
   {
      cout << "What is the value at \'" << letter << number << "\': ";
      cin >> value;
      for (int count = 0; count < 9; count++)
         {
            if (sudokuBoard[row][count] == value)
            {
            cout << "ERROR: Value \'" << value << "\' in square \'"
                 << letter << number << "\' is invalid\n";
            }
               else
                  sudokuBoard[letter - 'A'][number - 1] = value + 48;
         }
      
   }
   interact(sudokuBoard);
}
   
/**********************************************************************
 * Function will write the file to the file the user chooses
 ***********************************************************************/
void writeFile(char sudokuBoard[][9])
{
   //Declare file output
   char fileDestination[256];
   ofstream fout;

   //Asking for user input
   cout << "What file would you like to write your board to: ";
   cin  >> fileDestination;

   //Open destination file & error checking
   fout.open(fileDestination);

   //Writes board to file
   for (int row = 0; row < 9; row++)
   {
      for (int col = 0; col < 9; col++)
      {
         fout << sudokuBoard[col][row];
      }
     
   }  
   if (fout.fail())
   {
      cout << "Written unsuccessfully";
   }
   else
      cout << "Board written successfully\n";
   
   //Close file
   fout.close();
   exit(0);
}
Last edited on
I know there is some repetitive functions, but it was the only way I could past the testBeds, that I could think of.
What about a simple function like (not tested!):
1
2
3
4
5
6
bool checkCell(char sudokuBoard[][9], int col, int row)
{
    if(col < 0 || 8 < col || row < 0 || 8 < row) { return false; }
    if(sudokuBoard[col][row] != '0')             { return false; }
    return true;
}


to be called in a way similar to the following:
1
2
3
4
if(!checkCell(sudokuBoard, letter - 65, number -1) {
    cout << "ERROR: Square \'" << letter << number 
         << "\' is out of range or not empty.\n";
}


Am I misunderstanding your question?
yeah sorry I should have phrased it better, so I want it to check if the value in editBoard is valid like if it's already in the same column or same row or same square than it would return Error value(2 or whatever) in square A4 (or whatever) is invalid. Basically enforcing the rules of the game.
Sorry, Im’ not a native English speaker and sometimes I get hold of the wrong end of the stick. Anyway, here are some hints in a working code (it will take me more than one post):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#include <iostream>
#include <fstream>
// 2017-07-11 removed: #include <stdlib.h>
#include <cstdlib> // 2017-07-11 added. Anyway, is unused.
using namespace std;

void readFile(char sudokuBoard[][9]);
void displayOptions(char sudokuBoard[][9]);
void displayJustOptions();
void justDisplay(char sudokuBoard [][9]);
void display(char sudokuBoard[][9]);
void interact(char sudokuBoard[][9]);
void editBoard(char sudokuBoard[][9]);
void showValue (char sudokuBoard[][9]);
void writeFile(char sudokuBoard[][9]);

// 2017-07-11: added prototypes
bool checkColMatches(char sudokuBoard[][9], int col, char value);
bool checkRowMatches(char sudokuBoard[][9], int row, char value);
bool checkSquareMatches(char sudokuBoard[][9], int col, int row, char value);
bool checkCellRangesAndEmptiness(char sudokuBoard[][9], int col, int row);
bool checkCandidateforCell(char sudokuBoard[][9], int col, int row, char value);

/**********************************************************************
 * driver program for the functions below
 ***********************************************************************/
int main()
{
   char sudokuBoard[9][9];
   
   readFile(sudokuBoard);
   displayOptions(sudokuBoard);
   interact(sudokuBoard);
   return 0;
}

/**********************************************************************
 * reads the file back into our board[][] array.
 ***********************************************************************/
void readFile(char sudokuBoard[][9])
{
   char initialFile[256];

   ifstream fin;
   
   cout << "Where is your board located? ";
   cin >> initialFile;

   fin.open(initialFile);
   if (fin.fail())
   {
      cout << "Error reading file";
   }
    
   for (int row = 0; row < 9; row++)
   {
      for (int col = 0; col < 9; col++)
      {
         fin >> sudokuBoard[col][row];
      }
   }
   fin.close();
}

/**********************************************************************
 * displays the suduko board and replaces zeros with null characters.
 ***********************************************************************/
void display(char sudokuBoard[][9])
{
   // display sudoku board row by row
   cout << endl
        << "   A B C D E F G H I\n";
   
   for (int row = 0; row < 9; row++)
   {
      cout << row + 1 << "  ";
      for (int col = 0; col < 9; col++)
      {
         if (sudokuBoard[col][row] == '0')
            cout << " ";
         else 
            cout << sudokuBoard[col][row];
         if (col == 2 || col == 5)
            cout << "|";
         else if (col != 8)
            cout << " ";
      }
         
      if (row == 2 || row == 5)
         cout << "\n   -----+-----+-----\n";
      else
         cout << endl;
   }
}

/**********************************************************************
 * displays the suduko board and replaces zeros with null characters.
 ***********************************************************************/
void justDisplay(char sudokuBoard [][9])
{
   cout << "   A B C D E F G H I\n";

   for (int row = 0; row < 9; row++)
   {
      cout << row + 1 << "  ";
      for (int col = 0; col < 9; col++)
      {
         if (sudokuBoard[col][row] == '0')
            cout << " ";
         else 
            cout << sudokuBoard[col][row];
         if (col == 2 || col == 5)
            cout << "|";
         else if (col != 8)
            cout << " ";
      }

      if (row == 2 || row == 5)
         cout << "\n   -----+-----+-----\n";
      else
         cout << endl;
   }
}

/**********************************************************************
 * displays the suduko board and replaces zeros with null characters.
 ***********************************************************************/
void displayJustOptions()
{
   cout << "Options:\n"
        << "   ?  Show these instructions\n"
        << "   D  Display the board\n"
        << "   E  Edit one square\n"
        << "   S  Show the possible values for a square\n"
        << "   Q  Save and Quit\n";
   cout << endl;
}

/**********************************************************************
 * displays the suduko board and replaces zeros with null characters.
 ***********************************************************************/
void displayOptions(char sudokuBoard[][9])
{
   cout << "Options:\n"
        << "   ?  Show these instructions\n"
        << "   D  Display the board\n"
        << "   E  Edit one square\n"
        << "   S  Show the possible values for a square\n"
        << "   Q  Save and Quit\n";
   display(sudokuBoard);
}

/**********************************************************************
 * function displays the options the gamer can choose from and proceed
 * to go to the option they choose.
 ***********************************************************************/
void interact(char sudokuBoard[][9])
{
   char option;
   while (true)
   {
      cout << endl;
      cout << "> ";
      cin >> option;
      if (option == '?')
         displayJustOptions();
      else if (option == 'D' || option == 'd')
         justDisplay(sudokuBoard);
      else if (option == 'S' || option == 's')
         showValue(sudokuBoard);
      else if (option == 'E' || option == 'e')
         editBoard(sudokuBoard); 
      else if (option == 'Q' || option == 'q')
         break;
   }
   writeFile(sudokuBoard);
}


/**********************************************************************
 * function will show all possible values for the coordinates entered
 ***********************************************************************/
void showValue(char sudokuBoard[][9])
{
   char letter;
   int number;
   
   cout << "What are the coordinates of the square: ";
   cin >> letter >> number;

   // 2017-07-11 removed: toupper(letter);
   letter = toupper(letter); // // 2017-07-11 added
   
   if (sudokuBoard[letter - 65][number - 1] != '0')
   {
      cout << "ERROR: Square \'" << letter << number <<
         "\'" << " is filled\n";
   }

   else
   {
      cout << "The possible values for " << letter << number
           << " are";

   }
} 
   
/**********************************************************************
 * function will edit a coordinate of the game board based on what
 * was entered
 ***********************************************************************/
void editBoard(char sudokuBoard[][9])
{
   char letter;
   int number; 
   // 2017-07-11 removed: int value;
   // 2017-07-11 removed: int row;
   // 2017-07-11 removed: int col;

   cout << "What are the coordinates of the square: ";
   cin >> letter >> number;

   letter = toupper(letter);



   if (sudokuBoard[letter - 65][number - 1] != '0')
   {
      cout << "ERROR: Square \'" << letter << number <<
         "\'" << " is filled\n";
   }
   else
   {
      cout << "What is the value at \'" << letter << number << "\': ";
      char value = '\0';
      cin >> value;
      if(!checkCandidateforCell(sudokuBoard, letter - 65, number - 1, value)) {
         cout << "ERROR: Value \'" << value << "\' in square \'"
              << letter << number << "\' is invalid\n";
      }
      else {
         sudokuBoard[letter - 'A'][number - 1] = value;
      }
   }
   interact(sudokuBoard);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**********************************************************************
 * Function will write the file to the file the user chooses
 ***********************************************************************/
void writeFile(char sudokuBoard[][9])
{
   //Declare file output
   char fileDestination[256];
   ofstream fout;

   //Asking for user input
   cout << "What file would you like to write your board to: ";
   cin  >> fileDestination;

   //Open destination file & error checking
   fout.open(fileDestination);

   //Writes board to file
   for (int row = 0; row < 9; row++)
   {
      for (int col = 0; col < 9; col++)
      {
         fout << sudokuBoard[col][row];
      }
     
   }  
   if (fout.fail())
   {
      cout << "Written unsuccessfully";
   }
   else
      cout << "Board written successfully\n";
   
   //Close file
   fout.close();
   exit(0);
}

// 2017-07-11: added functions
/* checkCellRangesAndEmptiness: returns false if any index is out of range or
 *                              if the cell is not empty.
 *                  Otherwise returns true.
 */
bool checkCellRangesAndEmptiness(char sudokuBoard[][9], int col, int row)
{
    if(col < 0 || 8 < col || row < 0 || 8 < row) { return false; }
    if(sudokuBoard[col][row] != '0')             { return false; }
    return true;
}

/* checkColMatches: returns true if any matches found in the same column.
 *                  Otherwise returns false.
 */
bool checkColMatches(char sudokuBoard[][9], int col, char value)
{
    for(int i{}; i<8; i++) {
        if(sudokuBoard[col][i] == value) { return true;}
    }
    return false;
}

/* checkRowMatches: returns true if any matches found in the same row.
 *                  Otherwise returns false.
 */
bool checkRowMatches(char sudokuBoard[][9], int row, char value)
{
    for(int i{}; i<8; i++) {
        if(sudokuBoard[i][row] == value) { return true;}
    }
    return false;
}

/* checkSquareMatches: returns true if any matches found in the same square.
 *                     Otherwise returns false.
 */
bool checkSquareMatches(char sudokuBoard[][9], int col, int row, char value)
{
    switch(col % 3) {
    case 1:
        col -= 1;
        break;
    case 2:
        col -= 2;
        break;
    default:
        break;
    }
    switch(row % 3) {
    case 1:
        row -= 1;
        break;
    case 2:
        row -= 2;
        break;
    default:
        break;
    }
    for(int i{col}; i<col+3; i++) {
        for(int j{row}; j<row+3; j++) {
            if(sudokuBoard[i][j] == value) { 
                return true;
            }
        }
    }
    return false;
}

/* checkCandidateforCell: returns true if value is a legitimate candidate for
                          cell[col][row].
                          Otherwise returns false;
 */
bool checkCandidateforCell(char sudokuBoard[][9], int col, int row, char value)
{
    if(!checkCellRangesAndEmptiness(sudokuBoard, col, row)) { return false; }
    if(checkColMatches(sudokuBoard, col, value))            { return false; }
    if(checkRowMatches(sudokuBoard, col, value))            { return false; }
    if(checkSquareMatches(sudokuBoard, col, row, value))    { return false; }
    return true;
}


Output:
Where is your board located? myGame.txt
Options:
   ?  Show these instructions
   D  Display the board
   E  Edit one square
   S  Show the possible values for a square
   Q  Save and Quit

   A B C D E F G H I
1  7 2 3|4    |1 5 9
2  6    |3   2|    8
3  8    |  1  |    2
   -----+-----+-----
4    7  |6 5 4|  2
5      4|2   7|3
6    5  |9 3 1|  4
   -----+-----+-----
7  5    |  7  |    3
8  4    |1   3|    6
9  9 3 2|     |7 1 4

> E
What are the coordinates of the square: B2
What is the value at 'B2': 2
ERROR: Value '2' in square 'B2' is invalid

> E
What are the coordinates of the square: B2
What is the value at 'B2': 1

> D
   A B C D E F G H I
1  7 2 3|4    |1 5 9
2  6 1  |3   2|    8
3  8    |  1  |    2
   -----+-----+-----
4    7  |6 5 4|  2
5      4|2   7|3
6    5  |9 3 1|  4
   -----+-----+-----
7  5    |  7  |    3
8  4    |1   3|    6
9  9 3 2|     |7 1 4


Your code is becoming hard to read: my unsolicited opinion is you’d better use classes.
thanks so much, yeah I don't think we have gone over classes yet, just taking my first c++ class.
would I need to change any of my void functions to int, I think it may be causing some issues b/c of the parameter passing? I'm still looking into it, but I was just wondering cause I got a few different errors regarding the functions created.
I see that it would work with c++ 11, but I'm using a different compiler, the problem is the initializer lists you are using {}, what would be a good alternative to use besides those to get the same thing done? Would it just be a for loop?
never mind I figured it out to work with it :D
Another quick question before I mark as solved, so I am trying to write a function that shows the possible values someone could possibly enter, there is obviously different ways to do this, but would one way is to create an array of {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} and go through each section, row, and column and eliminate a number based on if it sees it in that row, section, or column ? And if this can be done, how can you eliminate each item in this array of possible values? I think I understand how you would loop through the sudokuBoard just don't know how you would eliminate items found.
This is my edited possibleValues function that I need work on.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
void possibleValue(char sudokuBoard[][9])
{
   char letter;
   int number;
   int col;
   int row;
   char value;

   cout << "What are the coordinates of the square: ";
   cin >> letter >> number;

   toupper(letter);

   if (sudokuBoard[letter - 65][number - 1] != '0')
   {
      cout << "ERROR: Square \'" << letter << number <<
         "\'" << " is filled\n";
   }
else 
{
      int possibleValues = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
      for (int i = {}; i < 8; i++)
      {
         if (sudokuBoard[col][i] != possibleValues)
            return possibleValues;
      }
      for (int i = {}; i < 8; i++)
      {
         if (sudokuBoard[i][row] != possibleValues)
            return possibleValues;
      }
      for (int i = 0; i < 8; i++)
      {
         if (sudokuBoard[(row/3)*3][i] != possibleValues)
            return possibleValues;
      }
      cout << "The possible values for \'" << letter << number << "\'"
           << " are: " << possibleValues;



   }
   cout << endl << endl;
Last edited on
Hello alextexasfan12,

Line 13 is better written as letter = toupper(letter);. And also in other places in your program.

http://www.cplusplus.com/reference/cctype/toupper/?kw=toupper

Hope that helps,

Andy
Thanks Andy, I don't know why I didn't put that, but what do you think of my loop logic in my last reply, it's not working, but hopefully you understand what I'm trying to do, is it possible to eliminate numbers as you go through each row, section, and column?
To get the possible values, create a bit map with 9 bits, all set. Then go through the associated rows, columns, and square, and clear the bit for any value that you find.

The bits that remain set in the bitmap are the possible values for that square.

Once you have this function, you can use it to test whether a move is valid. Just get the possible values and see if the proposed value is one of them.

Other comments on your code:
display() and justDisplay() are identical. Remove one of them.

displayOptions() should just display the options. It shouldn't display the board. If the caller wants to display the board after displaying options then let them worry about it. This follows a simple but powerful principle of programming: functions and methods shouldn't necessarily do the work, they should make doing the work easy.

editBoard() should not call interact(). Just return and let the loop in interact run again.
cout << "Where is your board located? ";
If I saw this, I'd enter the path of the directory where the file is located, not the file itself. After all, if the board is /usr/dave/sudokuBoard.dat, then it's located in /usr/dave/
yeah we haven't gone over bit maps at all, so is there another way I could do it, similar to my loops that I tried to use or something like that? For some reason in my editBoard function it is stopping at that statement and thinking all board pieces are filled, it's using the same loginc as the editboard function for the conditionals, so I have no idea what's going on.
Last edited on
Topic archived. No new replies allowed.