My code for vigenere.c works for check50, but ends up being much longer than caesar.c in the encipher part.I was wondering if I was missing a simple point and have meandered through the logic behind it? I couldn't find another better way to avoid jumping to the next element of key shift if the character is not alphabetic!
I'm sure there is a less messy solution to vigenere?
Here is the encipher part of my code for vigenere.c
int i = 0;
int l = -1;
do
{
if (isalpha (p[i]))
{
do{
l++;
if (isupper (p[i]))
{
printf ("%c", (p[i] - 65 + k[l%m])% 26 + 65);
}
else
{
printf ("%c", (p[i] - 97 + k[l%m])% 26 + 97);
}
i++;
}while (isalpha(p[i]));
}
else
{
printf ("%c", p[i]);
i++;
}
} while ( i < n);