I made this program and seems that doesn't work can you tell me why? I spent like 3 hours just figuring out why it's not working but I have no clue. I'm wondering if it's not something with shift but I'm not sure. That's my first program I'm making so sorry about some basic mistakes.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
char message[100];
int shift;
int i;
int choice;
printf("Enter operation with message\n");
printf("encrypt - 1\n");
printf("decrypt - 2\n");
scanf("%d", &choice);
switch(choice)
{
case 1:
{
printf("Enter message to encrypt\n");
scanf("%d", &message);
printf("Enter shift\n");
scanf("%d", &shift);
for (i = 0; message[i] != '\0'; i++)
{
message[i] = message[i] + shift;
if (message[i] > 'z')
message[i] = message[i] - 26;
}
printf("Encrypted message: %s\n", message);
break;
}
case 2:
{
printf("Enter message to decrypt\n");
scanf("%d", &message);
printf("Enter shift\n");
scanf("%d", &shift);
for (i = 0; message[i] != '\0'; i++)
{
message[i] = message[i] - shift;
if (message[i] > 'z')
message[i] = message[i] - 26;
}
printf("Decrypted message: %s\n", message);
break;
}
}
return (EXIT_SUCCESS);
}
Here a screen of output: