alright so i figured out what to do about my code but what i have so far wont run...any help would be apprecieated...
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define WORDSEARCH "WordSearch.txt" // The Puzzle
#define WORDLIST "WordList.txt" // The List of Words
#define ROWS 15 // The # of Rows
#define COLS 15 // The # of Columns
typedef struct {
int row;
int col;
} pos_st;
/* Declaring the Functions */
void Print_Puzzle ( FILE *ptr1 , char WordSearch [ROWS][COLS]);
/* Main is used to open all the files and to scan the puzzle and the words
** into the program. It then receives the functions. */
main ()
{
int i,located;
char WordSearch[ROWS][COLS];
char temp[50]; //temporary char to hold the words
char *nptr;
FILE *ptr1 = NULL;
FILE *ptr2 = NULL;
FILE *ptr3 = NULL;
/* Opening the txt file with the puzzle in it */
/* The puzzle will be opened in a 2-D array and then closed */
ptr1 = fopen( WORDSEARCH , "r");
if (!ptr1)
{
printf("File not Found");
exit (0);
}
/* Opening the txt file with the words to search for in it */
/* The word list will be left opened so it is easy to access */
ptr2 = fopen(WORDLIST , "r");
if (!ptr2)
{
printf("File not Found");
exit (0);
}
/* Opening the txt file to store the output in */
/* The output will be left open to keep storing data in it */
ptr3 = fopen("Output.txt" , "w");
if (!ptr3)
{
printf("File not Found");
exit (0);
}
Print_Puzzle(ptr1 , WordSearch);
fclose(ptr1);
ptr1 = NULL;
for (i=0; !(feof(ptr2)); i++)
{
fgets(temp,sizeof temp, ptr2);
if ( (nptr = strchr (temp, '\n')) != NULL)
{
*nptr = '\0';
located = find (WordSearch, temp);
}
}
return 0;
}
void Print_Puzzle( FILE *ptr1, char wordsearch[ROWS][COLS])
{
int row, column, i;
printf("subscript by [across,vertical]\n\n\n ");
for (i=0; i< COLS ; i++)
{
printf("%i", i);
}
printf("\n %c", 218);
for (i=0; i<= ROWS ; i++)
{
printf("%c", 196);
}
printf("\n");
for( row = 0; row < ROWS; row++)
{
printf(" %i%c ", row, 179);
for (column = 0; column <= COLS; column++)
{
wordsearch[row][column] = fgetc(ptr1);
printf("%c", wordsearch[row][column]);
}
}
}