I need to make an encrypt/decrypt Caesar algorithm that asks for the user to put in a key. The following is what I have so far, I started off doing a rot-13 and tried to progress but as you can see, ran into a couple of problems. It is not complete yet because I have to ask for character input, but I'm having trouble seeing where I need to add a string array. Can anyone point me in the right direction and maybe give me a hint on what to do? Thanks.
Code:#include<stdio.h> int main() int crypt; int x,y; int key; char input; { printf("Do you want your characters encrypted [1] or decrypted [2]? \n"); scanf("%d", crypt); printf("Enter a key"); scanf("%d", key); while((x=getchar())!=EOF && crypt=1) { printf("Enter data to encrypt.\n"); fflush(stdin); gets(input); if(x >='A' && x <='Z') { if((y = x + key) <= 'Z') putchar(y); else { y = x - key; putchar(y); } } else if(x >='a' && x <='z') { if((y= x + key) <= 'z') putchar(y); else { y = x - key; putchar(y); } } else putchar(x); } return 0; }