Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(){
- FILE* input;
- FILE* output;
- char** inglese;
- char** italiano;
- char riga[1001];
- int index,i,n;
- input=fopen("input.txt","r");
- output=fopen("output.txt","w");
- if(input==NULL || output==NULL)
- printf("Impossibile Leggere il File!");
- fscanf(input,"%d",&n);
- inglese= (char**) malloc(n*sizeof(char*));
- italiano= (char**) malloc(n*sizeof(char*));
- for (i=0;i<n;i++){
- *(inglese+i)=(char*) malloc(101*sizeof(char));
- *(italiano+i)=(char*) malloc(101*sizeof(char));
- fscanf(input,"%s %s",*(inglese+i), *(italiano+i));
- }
- while(fscanf(input,"%s",riga)!=EOF){
- for (i=0;i<n;i++){
- if (strcmp(riga,*(inglese+i))==0)
- {index=i; break;}
- }
- fprintf(output,"%s ",*(italiano+index));
- }
- fclose(input);
- fclose (output);
- for (i=0;i<n;i++){
- free(*(inglese+i));
- free(*(italiano+i));
- }
- free(inglese); free(italiano);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement