Advertisement
Guest User

Untitled

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