Urgent find word from file inc hepl

March 21, 2009 at 01:04:34
Specs: Windows Vista
Hi Guys,
could any one help me with this program to find the solution for it.
The program is a list file contain words and find this words from grid list file
EX
the grid list is
FIRE
IROA
TBEB
SITS
and the list file is
FITS
FIRE
ROE
DONKEY
FIR
the out put should be
FIR
FIRE
FITS
ROE

See More: Urgent find word from file inc hepl

Report •


#1
March 21, 2009 at 01:29:36
Not clear what's needed.


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
March 23, 2009 at 04:32:27
I did this so far but it's still i have problem and I am not sure how to do the search word for all the dimantions.
thanks
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define max_size 20
#define NOT_FOUND 0
#define FOUND 1

int read_letter(char *listfile[max_size][max_size],FILE *gridlist);
int searchword(char *gridlist[max_size][max_size],int d, FILE *wordlist);


int main ()
{
char *search_word[max_size][max_size];
search_word[max_size][max_size] =(char*)malloc(50);
search_word[0][0]='\0';

int size;
FILE *gridlistl_fptr;/*points to gridlist letter file*/
FILE *wordlist_fptr;/*points to words file*/

/*Open the grid list file and chek if it's null*/
gridlistl_fptr=fopen("gridlist.txt","r");
if(gridlistl_fptr==NULL)
{
printf("we could not open the grid file");
exit (1);
}

/*Open the listfile and check if it's null*/
wordlist_fptr=fopen("wordlist.txt","r");
if(wordlist_fptr==NULL)
{
printf("we could not open the word file");
fclose(wordlist_fptr);
exit (1);
}

/*store the squre array in the size*/
size=read_letter(search_word,gridlistl_fptr);

/*anlyze the array */
searchword(search_word,size,wordlist_fptr);

/*if it is success terminate this program*/

free(search_word[max_size][max_size]);
return EXIT_SUCCESS;
}/*end the main program*/

/*read the array from this function*/
int read_letter(char *listfile[max_size][max_size],FILE *gridlist)
{
int d;/*the dimantion of the square array*/
char *next_char;/* read the char from the file*/
char newline;

/*Now we get the dimantion of the square list and the new line also*/
fscanf(gridlist,"%d",&d);
fscanf(gridlist,"%s",&newline);

/*Now we fill the array*/
for(int row=1;row<=d;row++)
{
for(int col=1;col<=d;col++)
{
fscanf(gridlist,"%c%*c",&next_char);
listfile[row][col]=next_char;
}
fscanf(gridlist,"%c%*c",&newline);
}/*end for*/

/*Now we return the dimantion*/
return d;
}


int searchword(char *gridlist[max_size][max_size],int d, FILE *wordlist)
{
int row,col,ch,f,count;
char *search_word[20]; /*this array will read from the wordlist file*/
search_word[20]=(char*)malloc(10);
search_word[0]='\0';
int lengthsearch_word,lengthgrid_list;
lengthsearch_word=strlen(search_word[20]);
lengthgrid_list=strlen(gridlist[max_size][max_size]);


while(fscanf(wordlist,"%s",search_word)!=EOF)
{
f=NOT_FOUND;
for(row=1;row<=d;row++)
{
for(col=1;col<=d;col++);
{
for(ch=1;ch<=20;ch++)
{
if(gridlist[row][row+1]== search_word[ch]);
}
count++;
}
}


}
}


Report •

Related Solutions


Ask Question