0

This segment of code only prints out blank lines. Key is the correct integer, but I must be handling the array of characters incorrectly. Thoughts?

int key = atoi(argv[1]); 

for (int i = 0, c = strlen(plain); i < c; i++)      //declare both variables in one    
   {
     char ciphered[c]; 
     ciphered[i] = (plain[i] + key - 64) % 26;
     printf("%c\n", ciphered[i]);

   }

}

1 Answer 1

0

Probably because its encoding the plaintext to a number between 0 and 25 inclusive. Those numbers are non-printable ASCII codes. The number needs to be converted back to an ASCII code for an actual letter.

BTW, along with that, how does the code handle lower case vs. upper case plaintext?

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .