I spent about a week on this problem and just cannot figure out how to solve this. I am still needed to 1. reject an alphanumberic key and 2. do not increment if the character is anything other is isalpha. Can someone please point me in the right direction on how to solve these last two questions? is there no other way to reject an alphanumeric key other than doing a for loop on each character? thank you
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(int argc, string argv[])
{
if (argc == 2)
{
string text = get_string();
// changes key to integer//
int cipher;
for (int i=0; i<strlen(text); i++)
{
int chr = text[i];
int x = i % strlen(argv[1]);
if (isalpha(chr) && isupper(chr))
{
cipher = ((chr-65+argv[1][x]+65) % 26)+65;
}
else if (isalpha(chr) && isupper(chr))
{
cipher = ((chr-65+argv[1][x]+65) % 26)+65;
}
else if (isalpha(chr) && islower(chr)&& islower(argv[1][x]))
{
cipher = ((chr-97+argv[1][x]-97) % 26)+97;
}
else if (isalpha(chr) && islower(chr)&& isupper(argv[1][x]))
{
cipher = ((chr-97+argv[1][x]-65) % 26)+97;
}
else{
cipher = chr;
}
printf("%c", cipher);
}
}
// how to reject when user enters a number?//
else{
printf("ENTER A WORD!!\n");
return 1;
}
printf("\n");
return 0;
}