467,903 Members | 1,884 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,903 developers. It's quick & easy.

how to write Wikipedia Caesar cipher ,please help!

Plaintext: a  n i c e  d a y
Key: -3
Ciphertext: X  k f Z b  a X v

Cipher will accept commands from the user and perform the operations required by the commands. There are three different commands. Key command starts with "K1:"followed by a string as the key. Encryption command starts with "E1:" followed by the plaintext. Decryption command starts with "D1:" followed by the ciphertext to be decrypted. After the user inputs an encryption (or decryption) command, Cipher1 should encrypt the plaintext (or decrypt the ciphertext) using the key input by a previous key command, and print the results. The error message "key not found" should be printed if the user inputs an encryption or decryption command before a key command. If the user
inputs multiple keys, the latest key will be used in the following encryption/decryption operations. Below are two examples (underlined text is the input from the user, and italic text is the output of Cipher).
When the plaintext/ciphertext includes non-letter symbols, Cipher1 will ignore them.For example, a plaintext of "No. 2" is equivalent to "No".

Example I of Cipher:
K 1: 3
E 1: I  l i k e  d o g s
C i p h e r t e x t  i s < L  o l n h  g r j v >
D 1: L  o l n h  g r j v
P l a i n t e x t  i s < I  l i k e  d o g s >
E 1: H e l l o
C i p h e r t e x t  i s <K h o o r>

Example II of Cipher:
E 1: I  l i k e  d o g s
K e y  n o t  f o u n d
K 1: -54
E 1: H e l l o
C i p h e r t e x t  i s <F c j j m>
K 1: h h h h
Invalid  K e y

l just learn C program not long time ago,it is too diffcult for me to write,please tell me how it is

l writed only
char sen[100], x[100],k[100];
int i, num;


for (i=0; i< strlen(sen); i++)


for (i=0; i< strlen(sen); i++)


return 0;
Nov 19 '06 #1
  • viewed: 7436
1 Reply
maybe ,
could anyone tell me what function should l use in this program?
Nov 20 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Michael Sparks | last post: by
4 posts views Thread by Carl Harris | last post: by
9 posts views Thread by Piotr Turkowski | last post: by
24 posts views Thread by Luis M. González | last post: by
2 posts views Thread by Julio C. Hernandez Castro | last post: by
2 posts views Thread by thatos | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.