I am unable to make my key wrap around. The first three letters are working, however, after those, the program stops working and outputs garbage (or really secure cipher :))
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community
After the first pass through the key, every char in the key has been converted to numbers between 0 and 25 inclusive. Starting on the second pass through, the else clauses are executing, moving the key values into negative numbers. The results now become garbage.
The concept of converting the key to numbers from 0 to 25 is good. You just need to do it only once. Maybe you might consider a for loop to convert the key array once before starting the for loop to process the plain text?
Also, you have another error waiting in the wings. What about upper vs. lower case in the plain text?
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)