Advertisement
shadowsofme

GenerateKey

Oct 3rd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. char generateKey(char * ch)
  2. {
  3.     int i, j, n;
  4.     bool check1 = true, check2 = true; 
  5.     int length = strlen(ch);
  6.     printf("%s: %d\n", ch, length);
  7.     char *alphabet = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
  8.     char *endkey = "";
  9.     for (i = 0; i < length; i++){
  10.         n = strlen(endkey);
  11.         printf("%s: %d\n", endkey, n); 
  12.         for (j = 0; j < n; j++){       
  13.             if (endkey[j] == ch[i]){
  14.                 printf("Hi.\n");
  15.                 check1 = false;
  16.             }        
  17.         }
  18.         if (check1 != false){
  19.             strcat(i, endkey);
  20.         }
  21.         check1 = true;
  22.     }
  23.    
  24.     for (i = 0; i < strlen(alphabet); i++){
  25.         for (j = 0; j < strlen(endkey); j++){
  26.             if (alphabet[i] == endkey[j]){
  27.                 check2 = false;
  28.             }
  29.         }
  30.         if (check2 != false){
  31.             strcat(i, endkey);
  32.         }
  33.     }
  34.    
  35.     return endkey;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement