Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

x.Hme the only question I need help with to insert into my program but I am stru

ID: 3615310 • Letter: X

Question

x.Hme the only question I need help with to insert into my program but I am struggling to get it to work. I know it goes into my main function. (My Work Is Underneath). Can I get some help Please?

These question is what I am having problem with:
Here are the criteria for whether or not a real word should end up on this list:
2) If either string is a subsequence of the other and the lengths of the two strings are
within 2 of one another. (This would get rid of the “car”, “camera” case, for
example.)
3) If the strings are permutations of one the other. (Only try this test if the two
strings are of the same length.)
4) If the matchscore between the two strings is less than 3. (Only try this test if the
two strings are of the same length.)

Continue prompting the user to enter words until they decide that they don’t want to enter
any more. (Thus, they will be forced to enter the first word, but after that, you’ll provide
them a choice as to whether or not they want to enter another word to check.

Heres the link to my Assignment:
http://www.eecs.ucf.edu/courses/cop3223/fall2009/section1/Program5.pdf
______________________________________________________________________________


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int substring(char shortstr[], char longstr[]);
int subsequence(char shortstr[], char longstr[]);
int permutation(char string1[], char string2[]);
int matchscore(char string1[],char string2[]);


int main(void)
{
    FILE *dictionary;
   
    int total_number_words, n = 0;
    char words_list[30000][20], word[20];
    int found;
    int mywordlength, dictionarywordlength;
   
    dictionary = fopen("dictionary.txt", "r");
   
    fscanf (dictionary, "%d", &total_number_words);
   
    for (n = 0; n < total_number_words; n++)
    {
        fscanf( dictionary, "%s", words_list[n]);    
    }
   
   
    printf (" Welcome to the Spell Checker! ");
    printf ("The dictionary has been loaded. ");
    printf ("Please enter the word you would like checked? ");
    scanf ("%s", word);
   
    found = 0;
    for( n = 0; n < total_number_words; n++ )
    {
       if( strcmp(word,words_list[n] ) == 0 )
       {
              found = 1;
              break;
       }
    }
    if( found == 1 ) printf (" Great, %s is in the dictionary. ", word);
    else
    {
        mywordlength = strlen(word);
        printf ("Not found, but here are the possible words you could of meant: ");
       for( n = 0; n < total_number_words; n++ )
       {
            dictionarywordlength = strlen(words_list[n] );
           
           if( abs(dictionarywordlength - mywordlength) <= 2 )
           {
               if( mywordlength > dictionarywordlength )
               {
                   if( substring(words_list[n], word) == 1 )
                       printf( " suggested word: %s", words_list[n] );
               }
               else
               {
                   if( substring( word, words_list[n] ) == 1 )
                       printf( " suggested word: %s", words_list[n] );  
               }
           }   
       }
    }
   
   
   
    fclose(dictionary);
   
    getch ();
   
    return 0;   
}

int matchscore(char string1[],char string2[])
{
    int length, x, score = 0;
   
    length = strlen(string1);
    for (x = 0; x < length; x++)
    {
        if ( string1[x] != string2[x])
            score++;      
    }
   
    return score;
}

int permutation(char string1[], char string2[])
{
    int length, x, score1[26], score2[26];

    length = strlen(string1);
   
    for( x = 0; x < length; x++ )
    {
         score1[x] = 0;
         score2[x] = 0;
    }
   
    for (x = 0; x < length; x++)
    {
       score1[string1[x] - 'a']++;
       score2[string2[x] - 'a']++;
    }
   
    for( x = 0; x < length; x++ )
    {
         if (score1[x] != score2[x])
             return 0;
    }
   
    return 1;
   
}

int substring(char shortstr[], char longstr[])
{
    int shortlength, longlength, shortx, longx;
    int score;
  &n

Explanation / Answer

Can I get some help Please?