From cb01b275015561ac09cd8fea43dc518acda35bc0 Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Sat, 5 Nov 2022 10:50:42 +0000 Subject: [PATCH] explicitly cast int maths to char --- src/crypt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crypt.c b/src/crypt.c index f593fca..9d269c7 100644 --- a/src/crypt.c +++ b/src/crypt.c @@ -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); } }