Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <string.h>
  5.  
  6. int main(int argc, char* argv[]){
  7.  
  8.     FILE *f1 = fopen(argv[1], "r"), *f2 = fopen("plikwy","w");
  9.     int param = atoi(argv[2]);
  10.  
  11.     if(argc < 3){
  12.         printf("BLAD ILOSCI PARAMETROW\n");
  13.         return 1;
  14.     }
  15.  
  16.     if (access(argv[1],R_OK) != 0){
  17.         printf("BLAD DOSTEPU DO PLIKU WEJSCIOWEGO");
  18.         return 1;
  19.     }
  20.    
  21.  
  22.     if(f1 == NULL){
  23.         perror("BLAD OTWARCIA PLIKU\n");
  24.         return 1;
  25.     }
  26.  
  27.     int ch;
  28.  
  29.     while(1) {
  30.         ch = fgetc(f1);
  31.         if (ch == EOF)
  32.             break; 
  33.         fprintf(f2,"%c",ch+param);
  34.     }
  35.  
  36.     fclose(f1);
  37.     fclose(f2);
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement