Okay so I decided to write a Caesar Cipher but with a twist. Rather than simply having a numeric key I decided that it would be cool to have a short word that corresponds to offset. That way the pattern is harder to track. An example would be something like encoding the phrase "helloworld" with a key being "bad" (which corresponds to an offset of 2, 1, 4), this would lead to the encoded message being "jfpnpaqspf". I know that my code works for a simple Caesar Cipher with a numeric key but I'm having trouble on the loop for the key value. Any suggestions would be greatly appreciated!
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
    cout << "Enter the message: " << endl;
    char msg[80];
    char *myptr;
    myptr = msg;
    unsigned char cipher = 0;
    cin >> msg;
    char key[79];
    char *ptr;
    ptr = key;
    unsigned char ltr = 0;
    cout << "Enter Key: " << endl;
    cin >> key;
    while (*myptr) {
        while (*ptr) {
            ltr = *ptr;
            *ptr = ltr;
            ptr++;
        }
        cipher = *myptr;
        cipher += *ptr;
        if (cipher > 'z') {
            cipher -= 26;
        }
        if (cipher < 'a') {
            cipher += 26;
        }
        *myptr = cipher;
        myptr++;
    }
    cout << "New Message: " << msg << endl;
}
 
    