Not sure why its messing up some characters .

when i test with the key bacon,it returns:

plaintext: Meet me at the park at eleven am ciphertext: Neg zf av uf pcx bt gzrwep oz

The t and the r in the plaintext is not shifted for some reason.

The code is attached below:


1 Answer 1


I see two issues:

if(text[i]== '\40')

What about other non-alphabetic characters?


This code is missing some wrap-around code. For example, encoding abc with xyz should result in xzb, wrapping around to the beginning of the alphabet. You should have done something like that in caesar already, you could probably copy most of that code (just add the dynamic key).

  • Indeed it's better not to check if there is a space, instead check if the character is alphabetic, and only shift it if it is. Commented Dec 5, 2019 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .