Advertisement
sellmmaahh

Datoteke-ORispiti.txt

Aug 9th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main ()
  5. {
  6.     char ime[10], prezime[15];
  7.     int br_bod;
  8.     FILE *ulaz, *izlaz;
  9.     ulaz=fopen("ORispiti.txt","r");
  10.     if (ulaz==NULL) {
  11.             printf("greska prilikom otvaranja datoteke.");
  12.     exit(1);
  13.     }
  14.     izlaz=fopen("Vise10.txt","w");
  15.     if (izlaz==NULL) {
  16.         printf("Greska prilikom otvaranja izlazne datoteke.");
  17.         fclose(ulaz);
  18.         exit(1);
  19.     }
  20.     while(fscanf(ulaz,"%15s %10s %2d\n",prezime,ime,&br_bod)!=EOF) {
  21.         if (br_bod>=10) {
  22.                 fprintf(izlaz,"%-15s %-10s %2d\n",prezime, ime, br_bod);
  23.         }
  24.     }
  25.     fclose(ulaz);
  26.     fclose(izlaz);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement