So im new to this site and im pulling out my hair trying to figure this last issue out with my program. Ive got my characters shifted and my ciphertext printed, yet i cannot for the life of me print out non-alphabetic characters in my output for ciphertext. Everytime I add in a new print line outside my isupper and islower conditions, it meshes both prints together (the ciphertext and plaintext) and then it will print my non-alphabetic characters.
{
printf("ciphertext: ");
for (int i = 0, n = strlen(p); i < n; i++)
{
if (islower(p[i]))
{
printf("%c", (((p[i] - 97 + key) % 26) + 97));
}
if (isupper(p[i]))
{
printf("%c", (((p[i] - 65 + key) % 26) + 65));
}
printf("%c", p[i]);
}
printf("\n");
return 0;
}
}