i am failing to see my fault in logic ....
if i run ./substitution qwertyuioplkjhgfdsazxcvbnm
and input plaintext: abc
instead on ciphertext: qwe
i get ciphertext: dvm
...i tried debug50 and it seems there are more cases when the 'if' applies ...but i don`t understand how that is possible.....
//generate an array of uppercase letters of the alphabet
//for lowercase letters just add 32 to each item
int upperalpha[N];
for (int i = 'A'; i <= 'Z'; i++)
{
upperalpha[i - 'A'] = i;
}
//get message from the user
string plaintext = get_string("plaintext: ");
//encript the message
for (int i = 0; i < strlen(plaintext); i++)
{
for (int j = 0; j < N; j++)
{
if (plaintext[i] == upperalpha[j] || plaintext[i] == upperalpha[j] + 32)
{
plaintext[i] = argv[1][j];
}
}
}
//output the cripded message
printf("ciphertext: %s\n", plaintext);
return 0;