This is my first time posting on here so bare with me. Having a little trouble with pset2 vigenere.c. I've been looking through the forums looking at all the questions pertaining to my question, but can not come up with anything. I have 4 "else if" statements to check if message[i] and key[j] are either lower or upper, but the out put comes out as "CaQGoh". At a complete loss on what the problem is. Below is my else if statements and thank you in advance for any input/help!
if (islower(message[i]) | islower(key[j]))
{
letter = message[i] - 97;
keyletter = key[j % keylength] - 97;
ciphertext = ((letter + keyletter) % 26) + 97;
j++;
}
else if (isupper(message[i]) | isupper(key[j]))
{
letter = message[i] - 65;
keyletter = key[j % keylength] - 65;
ciphertext = ((letter + keyletter) % 26) + 65;
j++;
}
else if (isupper(message[i]) | islower(key[j]))
{
letter = message[i] - 65;
keyletter = key[j % keylength] - 97;
ciphertext = ((letter + keyletter) % 26) + 65;
j++;
}
else
{
letter = message[i] - 97;
keyletter = key[j % keylength] - 65;
ciphertext = ((letter + keyletter) % 26) + 97;
j++;
}
I have also tried doing &&'s and the out put comes out as "CaQaun". Again any input will help greatly appreciated. Thank you again.