Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- FILE *f1;
- FILE *f2;
- if((f1=fopen("BazaAut.txt","r"))==NULL){
- printf("BLAD");
- exit(1);
- }
- if((f2=fopen("Zabytki.txt","w"))==NULL){
- printf("BLAD");
- exit(1);
- }
- int przebieg,pojemnosc,rocznik;
- char marka[30],model[30];
- while(!feof(f1)){
- fscanf(f1,"%s",marka);
- fscanf(f1,"%s",model);
- fscanf(f1,"%i",&przebieg);
- fscanf(f1,"%i",&pojemnosc);
- fscanf(f1,"%i",&rocznik);
- if((2018-rocznik)>25){
- fprintf(f2,"%s\n",marka);
- fprintf(f2,"%s\n",model);
- fprintf(f2,"%i\n",przebieg);
- fprintf(f2,"%i\n",pojemnosc);
- fprintf(f2,"%i\n",rocznik);
- fprintf(f2,"\n");
- }
- }
- fclose(f1);
- fclose(f2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement