-
Caesar Cipher
I did a search before joining here but couldn't find anything relating to what I'm working on...
I have to make a Caesar cipher program that enters a phrase (using getchar), then enters the shift amount and outputs the encrypted phrase. I need to make sure it "wraps around" as if the input letter was z, and shift was 3, it would turn into c. I also need to make sure to only shift letters, not punctuation.
I have no idea how to even start basically, that's the only guidance I've got. We haven't gotten to strings so I have to use getchar somehow, or an array but I'm not sure how I would do that.
Any advice or help would be greatly appreciated.
-
Start with whatever you know so far. Generally assignments are there to test what you have learnt and maybe push you slightly.
For this program you will need knowledge of things like input/output, loops and conditionals.
These are usually the first few chapters of any C tutorial/book. If you have a more specific question we are happy to help you.
-
Usually Caesar Cipher is also used as an intro to cryptography and modular arithmetic, so I'm a little bit surprised that you couldn't find anything with just the keywords "Caesar Cipher" in your favourite search engine.
Bye, Andreas
-
You must be VERY unlucky in your search. They're all over, so you may want to try again.
You should be using a char array[]. You can use getchar() to get the user's char, and then put it into the array. I strongly recommend you use a char array. You'll find it quite difficult to work with separate char variables in the program.
-
I appreciate the responses, I was basically just looking for where to start I guess. I'll try the getchar and put that into the array. Thanks for the help though!
-
It doesn't matter how big the problem is, my advice is to research what is being asked of you.
Your first stop should be wiki's Caesar cypher page.
Think about how you could do this with a variable.
-
There are no less than 17 pages listed on Google for Caesar cipher in C, but Wikipedia is always a good first step.
And please, no more misstatements of the facts. We get enough of that from our politicians. ;)