SHARE
TWEET

Untitled

a guest May 22nd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define N 20
  5.  
  6. void encoder(char text[], char *enc_text)
  7. {
  8.     int i, j;
  9.     int len = strlen(text);
  10.    
  11.     char alphabet[27] = { 'a','b','c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'Z' };
  12.     for (i = 0; i < len; i++)
  13.     {
  14.         for (j = 0; j < 27; j++) {
  15.             if (text[i] == alphabet[j])
  16.             {
  17.                
  18.                 enc_text[i] = alphabet[j + 1];
  19.             }
  20.         }
  21.     }
  22.     enc_text[i] = '\0';
  23. }
  24. int main()
  25. {
  26.     FILE *file;
  27.     if ((file = fopen("shif_text.txt", "a")) == NULL)
  28.     {
  29.         printf("fail");
  30.         getchar();
  31.         return ;
  32.     }
  33.  
  34.     char *text;
  35.     char *encode_t;
  36.  
  37.  
  38.     text = (char*)malloc(sizeof(char)*N);
  39.     gets(text);
  40.  
  41.     encode_t = (char*)malloc(sizeof(char)*N);
  42.     encoder(text, encode_t);
  43.  
  44.     fputs(encode_t, file);
  45.     fclose(file);
  46.  
  47.     system("pause");
  48.     return 0;
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top