Here is my code and it runs without giving errors. But it doesnt work right. Caesar Cipher basicly shifts forward alphabet when encoding with key value for example: for key=1 ABC->BCD so when decoding it should apply -1 to BCD and become ABC again.
I want to do this also with numbers as you can see on my code but just doesnt work right. Please help me fix it. Also here is the problem i get:http://imgur.com/a/zaLzZ
I found at your code several errors. I could write here a lot about these, But that would be pretty hard to me due my poor English language capabilities. Nonetheles, here I have a fixed version of your code, so you could look at the differences to your own. Good luck.
The -- message[x]; is just the applying of a -1 key to message[x].
At each decryption round we just switch each character to its predecessor. E.g. C will be changed to B and so on. Consider that we applying just a key of -1 at each decrypting round to the same message, so after 26 rounds of -1 we have gotten all decryption cases.
Consider, if you want a single decryption with a concrete key, you could just use the encrypting function with the negative value of the encryption key.