I'm working on the Vigenere problem and I've came up with the following code:
for (int i = 0, j= 0, p = strlen(s); i < p; i++, j++)
{
int b= (j % strlen(argv[1]));
if (isupper(s[i]))
{
if (isupper(argv[1][b]))
{
printf ("%c", ((((s[i] - 65) + (argv[1][b] - 65)) % 26) + 65));
}
else
{
printf ("%c", ((((s[i] - 65) + (argv[1][b] - 97)) % 26) + 65));
}
}
if (islower(s[i]))
{
if (isupper(argv[1][b]))
{
printf ("%c", ((((s[i] - 97) + (argv[1][b] - 65)) % 26) + 97));
}
else
{
printf ("%c", ((((s[i] - 97) + (argv[1][b] - 97)) % 26) + 97)); }
}
if(!isupper(s[i]) && !islower(s[i]))
{
printf("%c", s[i]);
}
However, the program applies the Vigeneres's cipher to all characters, including numbers and spaces. When the plaintext is:" Meet me at the park at eleven am", I get the ciphertext: "Negh ne og tjs qaty bt syfvgb bm". Could somebody help me? Thank you.