I am newbie in C and I will be glad for any help with this program:
Task:
User will enter 4-7 letters (for example 'ADFG').
I have detached text file which contains about several thousand of words
(for example:
- BDF
- BGFK
- JKLI
- NGJKL
- POIUE
etc.)
-its written in list without that marks
I want to make program, which find words from this text file, which are same as letters which user entered (In this case, when I entered ADFG it will find and display BDF, BGFK, NGJKL).
This is my code so far:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() 
{
    char enter[8],row[80];
    printf("4-7 different letteres: ");
    gets(enter);
    if (strlen(enter)>7 || strlen(enter)<4)
    {
        puts("incorrect number of letters"); 
        return 1;
    }
    typedef struct structure
    {
        char row[50];
    }Row;
    Row textrow[40000];
    FILE *file;
    file = fopen("words.txt","r");
    if (file==NULL)
    {
        printf("Error! File %s can not be opened.","words.txt");
        return 1;
    }
    int i=0;
    char words[30];
    while (!feof(file))
    {
        fscanf(file,"%s",&textrow[i].row[0]);
        for(int j=0;j<strlen(enter);j++)
        {
            for(int k=0;k<strlen(textrow[i].row);k++)
            {
                words=strchr(textrow[i].row[k],enter[j]);
                printf("%s",words);
            }
        }
        i++;
    }
    fclose(file);
    return 0;
} 
Thanks for any help.
 
     
     
    