explicitly cast int maths to char

This commit is contained in:
Roland W-H 2022-11-05 10:50:42 +00:00
parent c6b5f1bad7
commit cb01b27501
1 changed files with 3 additions and 3 deletions

View File

@ -38,7 +38,7 @@ void caesar_encrypt(char* str, int size, int key)
if (str[i] != ' ')
{
bool upper = isupper(str[i]);
str[i] += key - (upper ? 65 : 97);
str[i] += (char)key - (upper ? 65 : 97);
str[i] %= 26;
str[i] += (upper ? 65 : 97);
}
@ -51,8 +51,8 @@ void caesar_decrypt(char* str, int size, int key)
if (str[i] != ' ')
{
bool upper = isupper(str[i]);
str[i] = str[i] - key - (upper ? 65 : 97);
str[i] = mod(str[i], 26);
str[i] = str[i] - (char)key - (upper ? 65 : 97);
str[i] = (char)mod(str[i], 26);
str[i] += (upper ? 65 : 97);
}
}