SHARE
TWEET

Untitled

a guest Aug 20th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>//do exit(1);
  3. int main()
  4. {
  5.     FILE *f1;
  6.     FILE *f2;
  7.     if((f1=fopen("BazaAut.txt","r"))==NULL){
  8.         printf("BŁĄD ");
  9.         exit(1);
  10.     }
  11.     if((f2=fopen("Zabytki.txt","w"))==NULL){
  12.         printf("BŁĄD ");
  13.         exit(1);
  14.     }
  15.     char marka[30], model[30];
  16.     int przebieg, rocznik;
  17.     float pojemnosc;
  18.     while(!feof(f1))
  19.     {
  20.         fscanf(f1, "%s", marka);
  21.         fscanf(f1, "%s", model);
  22.         fscanf(f1, "%d", &przebieg);
  23.         fscanf(f1, "%d", &rocznik);
  24.         fscanf(f1,"%f", &pojemnosc);
  25.     }
  26.     if((2018-rocznik)>25)
  27.     {
  28.         fprintf(f2, "%s\n", marka);
  29.         fprintf(f2, "%s\n", model);
  30.         fprintf(f2, "%d\n", przebieg);
  31.         fprintf(f2, "%d\n", rocznik);
  32.         fprintf(f2,"%f\n", pojemnosc);
  33.        
  34.     }
  35.    
  36.     fclose(f1);
  37.     fclose(f2);
  38.     return 0;
  39.    
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top