The text file contains words. Remove all duplicate words from a file.
#include <stdio.h> int main(int argc, char *argv[]) { int i=0,count=0; char a[1000]; char b[100][1000]; FILE *file=fopen("1.txt", "r"); FILE *file2=fopen("2.txt", "w"); //извлекаем из файла в массив for(int i=0;!feof(file);i++){ fscanf(file,"%c",&a[i]); count++; } //записываем в файл по слову в каждую строку for(int i=0;i<count-1;i++){ if(a[i]==*" "){ fprintf(file2,"\n"); } else{ fprintf(file2,"%c",a[i]); } } fclose(file2); FILE *file3=fopen("2.txt", "r"); while(!feof(file3)){ fscanf(file3,"%s",b[i]); printf("%d) %s ",i+1,b[i]); i++; } fclose(file); fclose(file3); FILE *del_file = fopen("1.txt","w+"); for(int j=0;j<i;j++){ printf("'%s' and '%s'\n",b[j],b[j+1]); if(b[j] == b[j+1]){ //эти строки не хотят сравниваться printf("true %s ",b[j]); } fprintf(del_file,"%s ",b[j]); } fclose(del_file); printf("\n"); return 0; } I know what I’m doing in an idiotic way, but I don’t know how differently, the algorithm is as follows: we literally read data from a file into an array, write a word from another array, write a word to each line, then read them into lines, then read array of strings, the problem is that the strings do not compare with each other, the condition does not pass (it is marked in the code), what can it be and how to fix it?