I'm having trouble reading my textfile into a 9x9 wordsearch grid. So far it just reads the textfile as 1 line.
dictionary.txt:
COMPILE
COMPUTER
DEBUGGING
HELLO
LANGUAGE
GRAPHICS
LOOP
PRINT
PROGRAMME
WORLD
wordsearch_grid.txt:
9
E M M A R G O R P
C L U A U N L L D
O T A O F I L O I
M E U N J G E O K
P W H K G G H P Q
I C O M P U T E R
L L V R Z B A O X
E H O M L E Q G U
T N I R P D C O E
Having a separate row and column grid doesn't really make sense.
You can represent the 9x9 square of letters by a single vector of strings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
ifstream fgrid("wordsearch_grid.txt");
fgrid.ignore(9999, '\n');
vector<string> grid(row);
for (int r = 0; r < row; r++) {
grid[r].resize(column, '.');
for (int c = 0; c < column; c++)
fgrid >> grid[r][c];
}
// To print
for (int r = 0; r < row; r++)
cout << grid[r] << '\n';
Those variables at the top of your listing above are suspicious. They probably shouldn't be there. Use local varibles and member variables. And grid should probably be a member variable of the WordSearch class.