OCRudoku
v1.0
Resolve word grid with ease
|
Functions | |
void | toUppercase (char *word) |
void | printCoordinates (int startRow, int startCol, int endRow, int endCol) |
int | readFromFile (const char *filename, char ***board, int *boardSize, int **boardColSize) |
int | findCoordinates (char **board, int boardSize, int *boardColSize, const char *word, int *startRow, int *startCol, int *endRow, int *endCol) |
int findCoordinates | ( | char ** | board, |
int | boardSize, | ||
int * | boardColSize, | ||
const char * | word, | ||
int * | startRow, | ||
int * | startCol, | ||
int * | endRow, | ||
int * | endCol ) |
Finds the coordinates of a word in the board.
This function searches for a given word in a 2D character array (board). If the word is found, it sets the starting and ending coordinates of the word in the board. The search is performed in all 8 possible directions: right, down, diagonal down-right, diagonal up-right, left, up, diagonal up-left, and diagonal down-left.
board | A 2D character array representing the board. |
boardSize | The number of rows in the board. |
boardColSize | An array representing the number of columns in each row of the board. |
word | The word to search for in the board. |
startRow | A pointer to an integer to store the starting row index of the word. |
startCol | A pointer to an integer to store the starting column index of the word. |
endRow | A pointer to an integer to store the ending row index of the word. |
endCol | A pointer to an integer to store the ending column index of the word. |
void printCoordinates | ( | int | startRow, |
int | startCol, | ||
int | endRow, | ||
int | endCol ) |
Prints the coordinates of the start and end points.
This function takes the starting and ending row and column indices and prints them in the format (startCol,startRow)(endCol,endRow).
startRow | The starting row index. |
startCol | The starting column index. |
endRow | The ending row index. |
endCol | The ending column index. |
int readFromFile | ( | const char * | filename, |
char *** | board, | ||
int * | boardSize, | ||
int ** | boardColSize ) |
Reads a grid from a file and initializes the board.
This function opens a file containing a grid, reads its contents, and initializes the board and its dimensions. The grid must be at least 5x5. Memory is allocated for the board and its column sizes.
filename | The name of the file to read the grid from. |
board | A pointer to the 2D character array (grid) to be initialized. |
boardSize | A pointer to an integer to store the number of rows in the grid. |
boardColSize | A pointer to an integer array to store the number of columns in each row. |
void toUppercase | ( | char * | word | ) |
Converts a given word to uppercase.
This function takes a string (character array) as input and converts all lowercase alphabetic characters to their uppercase equivalents. The conversion is done in place, modifying the original string.
word | A pointer to the character array (string) to be converted. |