Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- int getTerms(FILE* file1, char** terms1)
- {
- char* term = (char*)malloc(10000);
- int currLen = 0, read, termsC1 = 0;
- while (!feof(file1))
- {
- fscanf(file1, "%s", term + currLen);
- currLen += strlen(term + currLen);
- if (term[currLen - 1] == '.')
- {
- currLen = 0;
- terms1[termsC1] = term;
- term = (char*)malloc(10000);
- termsC1++;
- fseek(file1, 1, SEEK_CUR);
- }
- else
- {
- term[currLen] = ' ';
- currLen++;
- }
- }
- return termsC1;
- }
- int main(int argc, char** const args)
- {
- FILE* file1 = fopen("Eng.txt", "r");
- FILE* file2 = fopen("Rus.txt", "r");
- FILE* output = fopen("Output.txt", "w");
- char** terms1 = (char**)malloc(sizeof(int) * 1000);
- char** terms2 = (char**)malloc(sizeof(int) * 1000);
- int termsC = getTerms(file1, terms1);
- getTerms(file2, terms2);
- for (int i = 0; i < termsC; ++i)
- fprintf(output, "%d) %s (%s)\n", i+1, terms1[i], terms2[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement