I have two different text files, one of them contains a text, the other one works as a dictionary. The dictionary has some words line by line with their description beside them separated by a comma. I'm supposed to search for all these words in the text and then replace them with their description.
I thought after opening both for reading, I should load their contents into two arrays, I'm just a bit confused about the dictionary part since it should be read line by line and then each line should be broken into two parts.
I just really need some ideas on how to start this task.
So far I have this:
void open_file(char* text, char* dict, char* final) {
FILE *t, *d, *f;
t = fopen(text, "r");
d = fopen(dict, "r");
f = fopen(final, "w");
fseek(d, 0, SEEK_END);
long fsize = ftell(d);
fseek(d, 0, SEEK_SET);
char line[fsize + 1];
char * x[fsize + 1];
int i=0;
while (!feof(d)){
fgets(line,sizeof line,d);
x[i] = strdup(line);
i++;
}
fclose(t);
fclose(d);
fclose(f);
}
int main() {
open_file("text.txt","dict.txt","final.txt");
return 0;
}