I was able to complete my code and it works when I "make Vigenere" however for some reason, it is outputting double the amount of letters than the plaintext. I figure it has something to do with my loop however I can´t figure it out. I would appreciate any assistance. I am attaching only the last part of my code associated with this. Thanks
//get key
string key = argv[1];
// get plaintext from user and save as plaintext variable
{
printf("plaintext:");
}
string plaintext = get_string();
// iterate over characters in string, check upper and lower case and encrypt
for (int i=0, j=0, n = strlen(plaintext); i < n; i++)
{
{
if (isupper(plaintext[i]) && isupper(key[j]))
{
printf("%c", (((plaintext[i]-65) + (key[j] - 65)) % 26) + 65);
}
else if (islower(plaintext[i]) && islower(key[j]))
{
printf("%c", (((plaintext[i]-97) + (key[j]-97)) % 26) + 97);
}
else if (islower(plaintext[i]) && isupper(key[j]))
{
printf("%c", (((plaintext[i] - 97) + (key[j] -65)) % 26) + 97);
}
else if (isupper(plaintext[i]) && islower(key[j]))
{
printf("%c", (((plaintext[i] - 65) + (key[j] - 97)) % 26) + 65);
}
j++;
}
{
printf("%c", plaintext[i]);
}
}
printf("\n");
return 0;
}