Advertisement
Guest User

zad2

a guest
May 26th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int main () {
  6.     FILE *in = fopen("BazaAut.txt", "r");
  7.     FILE *out = fopen("Zabytki.txt", "w");
  8.  
  9.  
  10.     char marka[30], model[30], przebieg[30], pojemnosc[30];
  11.     int rocznik;
  12.  
  13.     while ( !feof(in) ) {
  14.         fscanf(in, "%s", marka);
  15.         fscanf(in, "%s", model);
  16.         fscanf(in, "%s", przebieg);
  17.         fscanf(in, "%s", pojemnosc);
  18.         fscanf(in, "%d", &rocznik);
  19.  
  20.         printf("%s\n", marka);
  21.         printf("%s\n", model);
  22.         printf("%s\n", przebieg);
  23.         printf("%s\n", pojemnosc);
  24.         printf("%d\n", rocznik);
  25.        
  26.         if( rocznik < 1993 ) {
  27.             //printf("stary\n");
  28.             fprintf(out, "%s\n", marka);
  29.             fprintf(out, "%s\n", model);
  30.             fprintf(out, "%s\n", przebieg);
  31.             fprintf(out, "%s\n", pojemnosc);
  32.             fprintf(out, "%d\n", rocznik);
  33.         }
  34.     }
  35.  
  36.     fclose(in);
  37.     fclose(out);
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement