Advertisement
sellmmaahh

OR-2005-zad6

Aug 10th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main () {
  5.     FILE *ulaz,*izlaz;
  6.     ulaz=fopen("auto.txt","r");
  7.     if (ulaz==NULL) {
  8.             printf("Greska.");
  9.     exit(1);
  10.    
  11.     }
  12.     izlaz=fopen("auto88.txt","w");
  13.     if (izlaz==NULL) {
  14.         printf("Greska");
  15.         fclose(ulaz);
  16.         exit(1);
  17.     }
  18.     char prezime[15], ime [15], reg_oznaka[10];
  19.     int i=0,j;
  20.     while (fscanf(ulaz,"%15s %15s %9s",&prezime,&ime,&reg_oznaka)!=EOF){
  21.             char *temp=reg_oznaka;
  22.     int br8=0;
  23.     for (j=0; j<9; j++) {
  24.             if (*temp=='8') br8++;
  25.         temp++;
  26.     }
  27.     if (br8==2) {
  28.             fprintf(izlaz,"%15s %15s %9s",prezime,ime,reg_oznaka);
  29.     }}
  30.     fclose(ulaz);
  31.     fclose(izlaz);
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement