I started programming in C++ this year with the "Introduction to Programming" module I took. In it, we covered the basics of loops, arrays and functions. I want to learn more, and start writing my own simple programs though.
I decided to try and make a Caesar Cipher program, which reads in a string, reads the amount to shift the characters by, and prints the ciphertext.
So far, it only encrypts (I want to make sure everything is working first). Now, I'm a little stuck on where to go next.
Originally, I had the entire program in the main function. I tried to create a function for encryption and I know I've made a mistake, I just can't see where.
Here's my code so far:
REMOVED
Can someone help me out a little? It'd be greatly appreciated.
You never assign a value to cipher but you seem to expect it to contain your encrypted data for some reason. The variable "plain" should contain your encrypted data since you passed it by reference.
Sorry, my fault, I edited the post when I realised a stupid error, and forgot to change that.
Thank you.
I'm currently working on the code, trying to implement a switch menu for encrypting and decrypting.
It's a little messy, but I'll post it when I finish up.
Thanks for your reply. I was wondering what was causing the error. After some searching, I appended cin.ignore() after the choice in the menu function. That seems to have done the trick too.
I thought I was in the clear after that problem, however, my decrypt function isn't working properly at all.
REMOVED
When I use a simple shift, such as 4, my output becomes weird symbols.
e.g. If I input "e" as the ciphertext, with a shift of 4, I expect an "a". This isn't the case. My algorithm is all wrong, but I've been tinkering for the past hour to no avail.