The objective is to have the user input something like: "Hi, nice to meet you." and the code to be translated using a shift amount entered by the user. If h is shifted 3, the letter would be k. Here is my code thus far:
My issue is that the executable will ask for the input, and not ask for the shift amount. What can I do to solve this?
/* Caesar Cipher Project Input a message and a shift amount then prints out the encrypted message Programmer: Perry Chapman Date: 2/11/2013 */ #include <stdio.h> #include <string.h> int main (void) { int key = 0; char input[80]; int i; printf("Enter message to be encrypted: "); scanf("%s", &input); printf("\nEnter shift amount (1-25): "); scanf("%d", &key); for(i=0; input[i] != '\0';i++) { if (input[i]>='A' && input[i]<='Z') { input[i] = ((input[i] - 'A') + key) % 26 + 'A'; } else if (input[i]>='a' && input[i]<='z') { input[i] = ((input[i] - 'a') + key) % 26 + 'a'; } } printf("\nEncrypted message: %s", input); }
My issue is that the executable will ask for the input, and not ask for the shift amount. What can I do to solve this?