0

Below is my code. I would like to know why within the while-loop the code doesn't ask for another word(s1). The find_anagram function is omitted. How can I loop the program so that it asks for a new word every time the answer is 1?

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


int main(int argc, char *argv[]) {
    char s1[20];
    int answer;
    FILE *fp1;
    char leksi[100];
    fp1=fopen("C:/Users/inspiron/Desktop/englishWords.txt","r");
    answer=1;
    while(answer==1){
        fgets(s1,20,stdin);
        do {
            fgets(leksi,20,fp1);
            if(find_anagram(leksi,s1)==1){
                printf("%s",leksi);
            }
        } while (!feof(fp1));
        memset(leksi, 0, sizeof leksi);
        memset(s1, 0, sizeof s1);
        printf("Enter another word? yes(1) or no(0)?\n");
        scanf("%d",&answer);
    }        

    fclose(fp1);
    return 0;
}

0 Answers0