Basic encryption and strings

Hey, so i have been playing with trying to encrypt something in C++ but when i try to put my results into a string the string stays empty. I have tried to add lines to debug it a bit but with no luck. Any help would be great thanks!
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <string>
#include <iostream>

using namespace std;

string Encrypt(string what);

string charToInt(char aaa)
{
    switch (aaa)
    {        
        case 'a': return "100";
        case 'b': return "200";
        case 'c': return "300";
        case 'd': return "400";
        case 'e': return "500";
        case 'f': return "600";
        case 'g': return "700";
        case 'h': return "800";
        case 'i': return "900";
        case 'j': return "010";
        case 'k': return "011";
        case 'l': return "012";
        case 'm': return "013";
        case 'n': return "014";
        case 'o': return "015";
        case 'p': return "016";
        case 'q': return "017";
        case 'r': return "180";
        case 's': return "190";
        case 't': return "020";
        case 'u': return "021";
        case 'v': return "022";
        case 'w': return "023";
        case 'x': return "024";
        case 'y': return "025";
        case 'z': return "026";
    }
}
  
  
int main()
{
    cout << Encrypt("abc") << endl;
    int b;
    cin >> b;
    
}
        

string Encrypt(string what)
{
    int letter = 0;
    char a,b,c;
    string strEncrypt;
    for(int iii=0;iii<what.size();iii++)
    {
        a = charToInt(what[iii])[0];
        cout << "a = " << a << endl;
        b = charToInt(what[iii])[1];
        cout << "b = " << b << endl;
        c = charToInt(what[iii])[2];
        cout << "c = " << c << endl;
        strEncrypt =+ a;
        letter++;
        strEncrypt =+ b;
        letter++;
        strEncrypt =+ c;
        letter++;
        cout << "letter is " << letter << endl;
        cout << "Up to date string is "<< strEncrypt << endl;
    }
}
         

Topic archived. No new replies allowed.