This is in C language. When I call rotate() in main, the function returns false for isalpha() even though the string entered for plaintext uses alphabetic characters. Perhaps it’s identifying an alphabetic character by its ASCII value (‘A’ = 65)? I tried to test that out and used (char) with the letter variable in rotate() but it didn’t change anything.
PORTION OF MAIN
string plaintext = get_string("plaintext: ");
int length = strlen(plaintext);
char ciphertext[length];
for (int i = 0; i < length; i++)
{
ciphertext[i] = rotate(plaintext[i], key);
}
ROTATE FUNCTION
char rotate(char letter, int key)
{
if (isalpha(letter) == true)
{ ...
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.
Hope you enjoy the instance!
Follow the wormhole through a path of communities !webdev@programming.dev
I would drop the “== true” entirely. C will evaluate any nonzero int as true in an “if” statement.
Good point!