Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <unistd.h>
  4. #include <errno.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <time.h>
  8.  
  9. #define BUFSIZE 1024
  10.  
  11. void cipher(char *file)
  12. {
  13.     char buf[BUFSIZE];
  14.     FILE *f1;
  15.     int nread=-1;
  16.     char ch;
  17.     int i, n,m;
  18.    time_t t;
  19.    srand((unsigned) time(&t));
  20.    
  21.     f1 = fopen (file, O_RDONLY);
  22.     if(f1<0)
  23.         {
  24.             printf("Error is: %s\n", strerror(errno));
  25.             exit(1);
  26.         }
  27.      while ((ch = fgetc(f1)) != EOF)
  28.      {
  29.          printf("%c", ch);
  30.          n=rand()%9+1;
  31.          printf("%d",n);
  32.          for(i=0;i<n;i++)
  33.          {
  34.             printf("%c",rand()%26+97);
  35.          }
  36.          
  37.      }
  38. }
  39.  
  40. int main(int argc, char **argv){
  41.     cipher(argv[1]);
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement