modified array returns memory location/ will not write properly to file

Hi all. I was wanting to write a simple "password keeper" program to hide passwords to my various online accounts. The concept is that the user enters the password as a character array of a user-determined length,and the filename is the account. It takes the array, switches it over to type int and adds a "key" to generate the encrypted (if you can even call it that) password. This is the code:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <cstdlib>
#include <fstream>

using namespace std;

int main()
{

            int length;

    cout<<"Enter length of password in letters.\n";
    cin>>length;

            int carryint[length];
            char filename[50];
            char input[length];
            int counter=0;
            int key;
            char carry;

    cout<<"Next, enter the filename to write to\n ";
    cin>>filename;
    cout<<"Now, enter the key\n";
    cin>>key;
    cout<<"Now, enter the password to encrypt\n";
    cin>>input;



    do
    {

        input[counter]=carry;
        carryint[counter]=(int)carry+key;
        counter++;
           }

    while (counter<=length);

    cout<<"The output is:\n"<<carryint;

    ofstream out (filename);
    out<<carryint;
    out.close();

}


problem is, the output to the file is always something like ''>>>>>>>>>''
and the program gives me what appears to be a memory location as "carryint"

Thanks for your time helping this newb...
Topic archived. No new replies allowed.