error message: rejects https://sandbox.cs50.net/checks/742ebfdf355b45d594e8f23047837f51
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int main (int argc, string argv[])
{
if(argc != 2)
{
printf("type: ./vigenere key\n");
return 1;
}
string key = argv[1];
for(int i = 0, n = strlen(key); i < n; i++)
{
if (!isalpha(key[i]))
{
printf("type program name followed by non-numeric key\n");
return 1;
}
}
//takes user plain text to encrypt
//printf("plaintext: ");
string text = GetString();
int j = 0, k_len = strlen(key);
//printf("ciphertext: ");
for(int i = 0, n = strlen(text); i < n; i++)
if(isalpha(text[i]))
{
if(isupper(text[i]))
{
char cipher = (text[i] - 'A' + key[j % k_len] - 'A') % 26;
j++;
printf("%c", cipher + 'A');
}
if(islower(text[i]))
{
char cipher = (text[i] - 'a' + key[j % k_len] - 'a') % 26;
j++;
printf("%c", cipher + 'a');
}
}
else
{
printf("%c", text[i]);
}
printf("\n");
}