I am working on ceasar cipher for days and I don't know what I am doing wrong. My code is compiling. There are no errors anymore. But there is something wrong with my formula I guess. What's wrong with my formula?
for(int i = 0; i < length; i++)
{
char current = message[i];
char cipher[i];
char message[i];
if (isalpha(current))
{
if (islower(current))
{
cipher[i] = ((message[i] - 'a') + key) % 26 + 'a';
printf("%c", cipher[i]);
}
else if (isupper(current))
{
cipher[i] = ((message[i] - 'A') + key) % 26 + 'A';
printf("%c", message[i]);
}
}
}