Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. char* crypt (char* word)
  5. {
  6.     char values[] = "abcdefghijklmnopqrstuvwxyz";
  7.     static char String[5];
  8.     int i;
  9.     int key = 3;
  10.  
  11.     for (i = 0; i < strlen(word); i++)
  12.     {
  13.         char find = word[i];
  14.         const char *ptr = strchr(values, find);
  15.         int index = ptr - values;    
  16.         String[i] = values[index+key];
  17.        
  18.     }
  19.  
  20.     return String;
  21. }
  22.  
  23. int main(int argc, char *argv[])
  24. {
  25.     char word[5]="abcd";
  26.     char* result=crypt(word);
  27.     printf("%s\n", result);
  28.    
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement