Need help with Caesar Cipher.

Usually I am aboe to figure the things out with just a small pointer.... but this one escapes me.

I need to create a Caesar Cipher.

It must have an array. **
**I must be very simple.
(don't want to use that code where A = 65; just something that puts the characters into an array, so I can add 3 to each one and reprint).

Please no fancy tricks..... I don't have the skills or understanding to use them. Just need some help making a program that gets characters, puts them into an array, ads 3 to each one, and prints them back out.

My biggest problem at this point is how to PUT the characters into the array. I can use getchar to GET the characters, but how do I get them to go into the array?? Can't figure out what to do once I have the characters.

Thanks : )

3 Years
Discussion Span
Last Post by Unimportant

Thank you. That was extremely valuable (I had no idea such a place existed).

But the C program it gave did not use an array.

I have to use an array.


Thank you so much for your help.

I think the biggest problem is that I don't know how to get the character (not a number, but a letter) and put it into the array.

How do I do that?

It really needs to be specific to letters, because I don't have the skills to translate.


BTW---- just for the record--- title of this post of a typ-o, not a misspelling. I know it is cipher. I just didn't know how to fix it.


OK, are you ready? Don't fall asleep now.

Letters are numbers in a computer.
When you establish an array, you allocate a chunk of contiguous memory to crunch with.
In this case, you will need (1) times the number of characters required to hold your information.

That is to say, if you have some letter 'a' and you save it as an integer
int letter('a');
and then you subtract 'a'
letter -= 'a';
then letter == 0 or (!letter) is true

So if you have some arbitrary array letters[1024];
and a write position
int pos(0);
letters[pos++] = (get char result) + 3;
Then you're all OK.

I'm afraid I may have given you too much of the answer.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.