Advertisement
filip710

PROG2 LV7 Z3

Jun 29th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. /* Napišite program koji kopira jednu tekst datoteku u drugu pri čemu mijenja mala
  2. slova u velika. Datoteka sa iz koje se kopira se zove Prva.txt i pripremljena je samo za
  3. čitanje, a drugu datoteku, imena Druga.txt, trebate kreirati iz programa. */
  4.  
  5. #include<stdio.h>
  6. #include <ctype.h>
  7.  
  8. int main() {
  9.     FILE *f1;
  10.     FILE *f2;
  11.     int i;
  12.     char rec1[20];
  13.  
  14.     f1=fopen("Prva.txt","r");
  15.     if (f1==NULL){
  16.     printf("Greska prilikom otvaranja datoteke");
  17.     }
  18.     fgets(rec1,19,f1);
  19.     puts(rec1);
  20.  
  21.     for(i=0;rec1[i];i++)
  22.     {
  23.         if(islower(rec1[i])) rec1[i]=toupper(rec1[i]);
  24.     }
  25.     fclose(f1);
  26.     f2=fopen("Druga.txt", "w");
  27.  
  28.     if (f2==NULL){
  29.     printf("Greska prilikom otvaranja datoteke");
  30.     }
  31.    
  32.     fprintf(f2, "%s", rec1);
  33.  
  34.     fclose(f2);
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement