My code encrypts the messages I enter; however, the capital letters are printed twice, first the ciphertext (which is correct) then the plaintext that was entered by the user (ex. "Hello" with a key of 3 prints as "KHhoor".) Why is that 'H' printing? Any help is much appreciated!
int key = atoi(argv[1]);
int i, n;
s = GetString();
for(i = 0, n = strlen(s); i < n; i++)
{
if(isupper(s[i]))
{
printf("%c", (((s[i] + key - 'A') % 26) + 'A'));
}
if(islower(s[i]))
{
printf("%c", (((s[i] + key - 'a') % 26) + 'a'));
}
else
{
printf("%c", s[i]);
}
}