Advertisement
decs4usa

vigenere

Nov 9th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. #include <cs50.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6.  
  7.  
  8. int main(int argc, string argv[])
  9.    
  10. {
  11.     if (argc != 2) //if user doesn't run command-line argument of one or enter positive int  
  12.     {
  13.         printf("Usage: ./vigenere key\n"); //prompt them to run it again
  14.         return 1; //returning zero means everything went well
  15.     }
  16.    
  17.     for (int j = 0, n = strlen(argv[1]);  j < n; j++)  //length of the entire string. Save n as strlen for use in loop
  18.     {
  19.         if (isalpha(argv[1][j])) //if user doesn't run command-line argument of one or enter positive int and user inputs an alpha key, continue
  20.  
  21.         {
  22.             //printf("%c\n", argv[1][j]); //Print after collecting plaintext
  23.         }
  24.  
  25.    
  26.         else
  27.  
  28.         {      
  29.             printf("Usage: ./vigenere key\n"); //prompt them to run it again
  30.             return 1; //returning zero means everything went well
  31.         }
  32.  
  33.     }  
  34.    
  35.     string p = get_string("plaintext: "); //prompt for plaintext and store
  36.    
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement