int initializeProgram(){ char **dictionaryArray = NULL; char **wordSearchBoard = NULL; char c[MAX_STRING_LENGTH]; int wordCount, boardsToSolve, n = 1; // Opens dictionary file FILE *fileDictionary = fopen("dictionary.txt", "r"); // Verifies that the file opened properly. if (fileDictionary != NULL){ // Reads in the number of words in the // txt file based on the int on the first // line. fscanf(fileDictionary, "%i", &wordCount); // Calls a function that reads the file into a 2D // array. dictionaryArray = readFile(fileDictionary, wordCount); } else { return 1; } scanf("%i", &boardsToSolve); // Loops based on the number of // puzzles to be solved. while (boardsToSolve > 0){ int rows, cols, i, j; scanf("%i", &rows); scanf("%i", &cols); wordSearchBoard = createBoardArray(rows, cols); printf("Words Found Grind #%i\n", n); for (i = 0; i < rows; i++){ for (j = 0; j < cols; j++){ // Copies the function finding words to a useable vairbale. strcpy(c, searchBoard(i, j, 0, &wordSearchBoard, &dictionaryArray, wordCount, rows, cols, 0)); // Prints the word found from the board. printf("%s\n", c); } } n++; boardsToSolve--; } fclose(fileDictionary); // Frees the 2D array holding dicitonary. freeArray(dictionaryArray, wordCount); return 0; }
/* * populate board node's members */ void populateBoard(BoardNode newBoard, BoardNode ParentBoard) { newBoard->parentBoard = ParentBoard; newBoard->bitID = '\0'; createBoardArray(newBoard); newBoard->next = NULL; }