C++ Encryption Program Not Working

I have been writing a very basic encryption program in C++ where the user is asked to enter a message, and then a number with the same number of digits as the number of characters in the message. Then it converts each character in the message to the ascii number, and then adds the each digit in the number to the ascii, and then converts back to a character and returns the encrypted string. And the progress happens in reverse to decrypt. When I tried to encrypt “hello”, I got �����. Can someone please explain how I can fix this? I have not finished the code, but this is it so far:

#include <iostream>
using namespace std;

string encryptMsg(string msg)
{
    cout << "Enter a number that is " << msg.length() << " digits long: ";
    string codekey;
    cin >> codekey;
    char msgArr[msg.length()];
    int keyCode[msg.length()];
    int tempcount = 0;
    for(char& c : msg) {
        msgArr[tempcount] = c;
        tempcount++;
    };
    tempcount = 0;

    for(char& c : codekey) {
        keyCode[tempcount] = c;
        tempcount++;
    };
    double tempascii;
    for(int i = 0; i < (sizeof(msgArr)/sizeof(msgArr[0])); i++)
    {
        tempascii = msgArr[i];
        tempascii = tempascii + keyCode[i];
        msgArr[i] = tempascii;
    };
    string outmsg;
    for(int i = 0; i < (sizeof(msgArr)/sizeof(msgArr[0])); i++)
    {
        outmsg = outmsg + msgArr[i];
    };
    return outmsg;
}

string decryptMsg(string msg)
{
    char msgArr[msg.length()];
    int tempcount = 0;
    for(char& c : msg) {
        msgArr[tempcount] = c;
        tempcount++;
    };
    double tempascii;
    for(int i = 0; i < (sizeof(msgArr)/sizeof(msgArr[0])); i++)
    {
        tempascii = msgArr[i];
        tempascii = tempascii - 3;
        msgArr[i] = tempascii;
    };
    string outmsg;
    for(int i = 0; i < (sizeof(msgArr)/sizeof(msgArr[0])); i++)
    {
        outmsg = outmsg + msgArr[i];
    };
    return outmsg;
};

int main()
{
    string mode;
    string msg;
    cout << "Encryption Program" << endl;
    cout << "Would you like to encrypt or decrypt?" << endl;
    cin >> mode;
    if (mode == "encrypt" || mode == "Encrypt" || mode == "ENCRYPT" || mode == "1")
    {
        cout << "Encryption. ENTER MSG HERE: ";
        cin >> msg;
        cout << encryptMsg(msg);
    } else if (mode =="decrypt" || mode == "Decrypt" || mode == "DECRYPT" || mode == "2")
    {
        cout << "Decryption. ENTER MSG HERE: ";
        cin >> msg;
        cout << decryptMsg(msg);
    };
    return 0;
}

Thank you.

C++ Encryption Program Not Working